Skip to content

Instantly share code, notes, and snippets.

@Spring3
Created May 20, 2017 00:21
Webpack 2 config [node,react,babel,webpack]
const webpack = require('webpack');
const path = require('path');
module.exports = {
entry: './web/dynamic/react.js',
output: {
path: path.join(__dirname, 'web', 'static', 'js'),
filename: 'bundle.min.js'
},
target: 'node',
resolve: {
extensions: ['.js', '.jsx', '.json']
},
module: {
rules: [{
test: path.join(__dirname, 'web', 'dynamic'),
loader: 'babel-loader',
query: {
presets: ['es2016', 'es2017', 'react']
}
}, {
test: /\.json?$/,
exclude: /node_modules/,
loader: 'json-loader'
}]
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
mangle: true,
sourcemap: false,
beautify: false,
dead_code: true
})
],
watch: process.env.NODE_ENV !== 'production'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment