Created
September 28, 2015 20:34
-
-
Save msikma/750af47cbdbb869858fb 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
// Webpack config for creating the production bundle. | |
var path = require('path'); | |
var webpack = require('webpack'); | |
var CleanPlugin = require('clean-webpack-plugin'); | |
var ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
var strip = require('strip-loader'); | |
// Stats plugin. | |
var writeStats = require('./utils/write-stats'); | |
// Destination directory for our generated bundles. | |
var bundlePath = '../../deploy/bundles'; | |
module.exports = { | |
'devtool': process.env.STAGING === 'true' ? 'source-map' : false, | |
'context': path.resolve(__dirname, '..'), | |
'entry': { | |
'main': '../src/lib/client.js' | |
}, | |
'output': { | |
'path': path.join(__dirname, '../../deploy/bundles'), | |
'filename': '[name]-[chunkhash].js', | |
'chunkFilename': '[name]-[chunkhash].js', | |
'publicPath': '/bundles/' | |
}, | |
'module': { | |
'loaders': [ | |
{ | |
'test': /\.(jpe?g|png|gif|svg)$/, | |
'loader': 'url', | |
'query': { | |
'limit': 10240 | |
} | |
}, | |
{ | |
'test': /\.json$/, | |
'loader': 'json' | |
}, | |
{ | |
'test': /\.js$/, | |
'exclude': /node_modules/, | |
'loaders': [ | |
// Strip debug() statements. | |
// todo: verify | |
strip.loader('debug'), | |
'babel?stage=0&optional=runtime&plugins=typecheck' | |
] | |
}, | |
{ | |
'test': /\.scss$/, | |
'loader': ExtractTextPlugin.extract( | |
'style', | |
'css!autoprefixer?browsers=last 2 version!sass' | |
) | |
} | |
] | |
}, | |
'progress': true, | |
'resolve': { | |
'modulesDirectories': [ | |
'src', | |
'node_modules' | |
], | |
'extensions': ['', '.json', '.js'] | |
}, | |
'plugins': [ | |
// Cleans up old builds. | |
new CleanPlugin([bundlePath]), | |
// CSS files from the ExtractTextPlugin loader. | |
new ExtractTextPlugin('[name]-[chunkhash].css'), | |
new webpack.DefinePlugin({ | |
'__CLIENT__': true, | |
'__SERVER__': false, | |
'__DEVELOPMENT__': false, | |
// Whether to disable server-side rendering. | |
'__DISABLE_SSR__': false, | |
// Whether to display the Redux dev tools. | |
'__DEVTOOLS__': false | |
}), | |
// Ignore development requests. | |
new webpack.IgnorePlugin(/\.\/dev/, /\/config$/), | |
// Global variables. | |
new webpack.DefinePlugin({ | |
'process.env': { | |
// Bundles generated using this config are only used on the client. | |
'BROWSER': JSON.stringify(true), | |
// Useful to reduce the size of client-side libraries. | |
'NODE_ENV': JSON.stringify('production') | |
} | |
}), | |
// Optimizations. | |
new webpack.optimize.DedupePlugin(), | |
new webpack.optimize.OccurenceOrderPlugin(), | |
new webpack.optimize.UglifyJsPlugin({ | |
'compress': { | |
'warnings': false | |
} | |
}), | |
// Write the stats file for the server-side code. | |
function doWriteStats() { | |
this.plugin('done', writeStats); | |
} | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment