**/__test__",
"dist:dev": "./node_modules/.bin/webpack --config conf/webpack.dev.conf.js",
"dist:min": "./node_modules/.bin/webpack --config conf/webpack.min.conf.js",
"dist:production": "./node_modules/.bin/webpack --config conf/webpack.prod.conf.js",
"build": "npm run build:production & npm run dist:production & npm run dist:min"
webpack.min.prod.js
require('babel-register');
const webpack = require('webpack');
const PATHS = require('../config').PATHS;
const entries = require('./webpack.util.js').default; // thank you babel 6
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports ={
mode: 'production',
entry: entries(),
output: {
path: PATHS.PROD.JS,
filename: '[name].min.js' // Template based on keys in entry above
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
},
optimization: {
minimizer: [
new UglifyJsPlugin({
sourceMap: true,
uglifyOptions: {
output: {comments: false},
warnings: false
}
}),
],
},
plugins: [ // Plugins for optimization
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.DefinePlugin({'process.env.NODE_ENV': '"production"'})
],
resolve: {
extensions: ['.js', '.jsx']
}
};
webpack.prod.conf.js
require('babel-register');
const PATHS = require('../config').PATHS;
const entries = require('./webpack.util.js').default;
module.exports ={
mode: 'production',
entry: entries(),
output: {
path: PATHS.PROD.JS,
filename: '[name].js' // Template based on keys in entry above
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
},
plugins: [],
resolve: {
extensions: ['.js', '.jsx']
}
};
@webpack_ru
Обсуждают сегодня