Skip to content

Instantly share code, notes, and snippets.

@jum-s
Created May 18, 2016 15:49
Show Gist options
  • Save jum-s/d137bfe7e3f046c0dfa35a01bd4b6f37 to your computer and use it in GitHub Desktop.
Save jum-s/d137bfe7e3f046c0dfa35a01bd4b6f37 to your computer and use it in GitHub Desktop.
'use strict';
var path = require('path');
var webpack = require('webpack');
var StatsPlugin = require('stats-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var devServerPort = 3808;
var production = process.env.TARGET === 'production';
var config = {
entry: {
'application': './webpack/application'
},
output: {
path: path.join(__dirname, '..', 'public', 'webpack'),
publicPath: '/webpack/',
filename: production ? '[name]-[chunkhash].js' : '[name].js'
},
resolve: {
root: path.join(__dirname, '..', 'webpack')
},
plugins: [
new ExtractTextPlugin("[name].css", {allChunks: true}),
new StatsPlugin('manifest.json', {
chunkModules: false,
source: false,
chunks: false,
modules: false,
assets: true
})],
module: {
loaders: [
{test: /\.css$/, loaders: ExtractTextPlugin.extract("style-loader", "css-loader") }
]
}
};
if (production) {
config.plugins.push(
new webpack.NoErrorsPlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: { warnings: false },
sourceMap: false
}),
new webpack.DefinePlugin({
'process.env': { NODE_ENV: JSON.stringify('production') }
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin()
);
} else {
config.devServer = {
port: devServerPort,
headers: { 'Access-Control-Allow-Origin': '*' }
};
config.output.publicPath = '//localhost:' + devServerPort + '/webpack/';
config.devtool = 'cheap-module-eval-source-map';
}
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment