Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Dotos committed Aug 4, 2017
1 parent 26f200c commit 6f381ec
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 197 deletions.
2 changes: 2 additions & 0 deletions dist/Valine.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/Valine.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 0 additions & 124 deletions dist/bundle.js

This file was deleted.

9 changes: 8 additions & 1 deletion index.html → dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Hello</title>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="Valine.min.js"></script>
<script>
new Valine({
app_id: '3GiiCyXCrGbOIH3EelCfJ6yw-gzGzoHsz',
app_key: 'iuneD4hXPQImdHQSRE0aOcRF'
}, AV)
</script>
</head>

<body>
<div id="app"></div>
<script src="./dist/bundle.js"></script>
</body>

</html>
73 changes: 44 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
{
"name": "Valine",
"version": "1.0.0",
"description": "A simple comment system based on Leancloud.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rimraf dist && webpack --watch",
"dev": "node webpack.dev.server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/xcss/Valine.git"
},
"keywords": [
"Comment",
"Valine"
],
"author": "xCss",
"license": "ISC",
"bugs": {
"url": "https://github.com/xcss/Valine/issues"
},
"homepage": "https://github.com/xcss/Valine#readme",
"dependencies": {
"rimraf": "^2.6.1",
"webpack": "^3.4.1",
"webpack-dev-server": "^2.6.1"
}
{
"name": "Valine",
"version": "1.0.0",
"description": "A simple comment system based on Leancloud.",
"main": "/src/Valine.js",
"scripts": {
"test": "webpack",
"build": "webpack",
"dev": "node_modules/.bin/webpack-dev-server --colors --hot --inline --host 0.0.0.0",
"clear": "rimraf dist "
},
"repository": {
"type": "git",
"url": "git+https://github.com/xcss/Valine.git"
},
"keywords": [
"Comment",
"Valine"
],
"author": "xCss",
"license": "ISC",
"bugs": {
"url": "https://github.com/xcss/Valine/issues"
},
"homepage": "https://github.com/xcss/Valine#readme",
"devDependencies": {
"autoprefixer": "^7.1.1",
"babel-core": "^6.22.1",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.22.0",
"css-loader": "^0.28.4",
"exports-loader": "^0.6.3",
"file-loader": "^0.11.2",
"node-sass": "^4.5.0",
"postcss-loader": "^2.0.5",
"sass-loader": "^6.0.3",
"style-loader": "^0.18.2",
"url-loader": "^0.5.7",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5"
},
"dependencies": {
"leancloud-storage": "^3.0.4"
}
}
5 changes: 5 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
plugins: [
require('autoprefixer')
]
}
22 changes: 22 additions & 0 deletions src/Valine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Valine {
/**
* Valine constructor function
* @param {Object} opts
* @constructor
*/
constructor(opts, AV) {
// let avScript = document.createElement('script');
// avScript.src = '//cdn1.lncld.net/static/js/3.0.4/av-min.js';
// let s = document.getElementsByTagName("script")[0];
// s.parentNode.insertBefore(avScript, s);
if (AV && AV.version) {
this._av = AV;
this._av.init({
appId: opts.app_id,
appKey: opts.app_key
})
}
}
}

module.exports = Valine;
Empty file added src/Valine.scss
Empty file.
9 changes: 0 additions & 9 deletions src/js/index.js

This file was deleted.

File renamed without changes.
85 changes: 66 additions & 19 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,66 @@
var path = require('path');
var webpack = require('webpack');
module.exports = {
// 入口文件
entry: [
'./src/js/index.js',
'webpack/hot/dev-server', // 调用热重载hot
'webpack-dev-server/client?http://localhost:8080' // 添加webpack-dev-server客户端
],
output: {
path: path.join(__dirname, 'dist'), // 指定打包后的目录
publicPath: 'dist', // 指定资源文件引用的目录
filename: 'bundle.js' // 指定打包为一个文件 bundle.js
},
plugins: [
// 全局开启热代码替换
new webpack.HotModuleReplacementPlugin()
]
}
var webpack = require('webpack');
var path = require('path');
var autoprefixer = require('autoprefixer');

var libraryName = 'Valine';
var env = process.env.WEBPACK_ENV;
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, 'src');
var BUILD_PATH = path.resolve(ROOT_PATH, 'dist');

var plugins = [];
if (env !== 'dev') {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
sourceMap: true
})
);
}

module.exports = {
entry: './src/' + libraryName + '.js',

output: {
path: BUILD_PATH,
filename: libraryName + '.min.js',
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},

devtool: 'source-map',

devServer: {
publicPath: "/dist/",
inline: true,
port: 8088
},

module: {
rules: [{
test: /\.js$/,
loader: 'babel-loader',
include: APP_PATH,
options: {
presets: ['es2015']
}
},
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'postcss-loader',
'sass-loader'
],
include: APP_PATH
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=40000'
}
]
},

plugins: plugins
};
Loading

0 comments on commit 6f381ec

Please sign in to comment.