optimize webpack workflow
This commit is contained in:
parent
6f496ac41c
commit
ef1ae2b761
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Reference in New Issue