Created
May 18, 2016 15:49
-
-
Save jum-s/d137bfe7e3f046c0dfa35a01bd4b6f37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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