optimize webpack workflow

This commit is contained in:
DIYgod 2017-01-19 18:18:04 +08:00
parent 6f496ac41c
commit ef1ae2b761
No known key found for this signature in database
GPG Key ID: F8797DD1088C6506
2 changed files with 22 additions and 13 deletions

View File

@ -5,7 +5,8 @@
"main": "dist/APlayer.min.js",
"scripts": {
"test": "webpack",
"start": "webpack-dev-server --hot --progress --inline --host 0.0.0.0"
"build": "webpack",
"dev": "WEBPACK_ENV=dev webpack-dev-server --hot --progress --inline --host 0.0.0.0"
},
"repository": {
"type": "git",

View File

@ -2,23 +2,37 @@ var webpack = require('webpack');
var path = require('path');
var autoprefixer = require('autoprefixer');
var libraryName = 'APlayer';
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');
module.exports = {
devtool: 'source-map',
var plugins = [];
if (env !== 'dev') {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
minimize: true
})
);
}
entry: './src/APlayer.js',
module.exports = {
entry: './src/' + libraryName + '.js',
output: {
path: BUILD_PATH,
filename: 'APlayer.min.js',
library: 'APlayer',
filename: libraryName + '.min.js',
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
devtool: 'source-map',
devServer: {
publicPath: "/dist/",
},
@ -45,13 +59,7 @@ module.exports = {
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
],
plugins: plugins,
postcss: [
autoprefixer({