Skip to content

Instantly share code, notes, and snippets.

@ikushlianski
Created May 10, 2018 08:12
Show Gist options
  • Save ikushlianski/0e145db1868f07a0dbaa13d03bd7ac43 to your computer and use it in GitHub Desktop.
Save ikushlianski/0e145db1868f07a0dbaa13d03bd7ac43 to your computer and use it in GitHub Desktop.
Webpack 1 sample config
'use strict'
var path = require('path');
const webpack = require('webpack');
const NODE_ENV = process.env.NODE_ENV || 'development';
//const NODE_ENV = 'production';
module.exports = {
context: __dirname + "/frontend",
entry: {
home: "./home",
about: "./about",
common: ["./common", "./welcome"]
},
output: {
path: __dirname + "/public",
filename: '[name].js',
library: '[name]'
},
watch: NODE_ENV === 'development',
watchOptions: {
aggregateTimeout: 100
},
devtool: NODE_ENV == 'development' ? "cheap-inline-module-source-map" : null,
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(NODE_ENV),
LANG: '"ru"'
}),
new webpack.optimize.CommonsChunkPlugin({
name: "common"
})
],
module: {
loaders: [{
test: /\.js$/,
loader: 'babel?optional[]=runtime'
}]
}
};
if (NODE_ENV === 'production') {
module.exports.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: true,
unsafe: true
}
})
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment