diff options
Diffstat (limited to 'config/webpack.config.js')
-rw-r--r-- | config/webpack.config.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js new file mode 100644 index 00000000000..ea51c9d1af7 --- /dev/null +++ b/config/webpack.config.js @@ -0,0 +1,46 @@ +'use strict'; + +var path = require('path'); +var webpack = require('webpack'); +var StatsPlugin = require('stats-webpack-plugin'); + +var IS_PRODUCTION = process.env.NODE_ENV === 'production'; +var ROOT_PATH = path.resolve(__dirname, '..'); + +// must match config.webpack.dev_server.port +var DEV_SERVER_PORT = 3808; + +var config = { + context: ROOT_PATH, + entry: { + bundle: './app/assets/javascripts/webpack/bundle.js' + }, + + output: { + path: path.join(ROOT_PATH, 'public/assets/webpack'), + publicPath: '/assets/webpack/', + filename: IS_PRODUCTION ? '[name]-[chunkhash].js' : '[name].js' + }, + + plugins: [ + // manifest filename must match config.webpack.manifest_filename + // webpack-rails only needs assetsByChunkName to function properly + new StatsPlugin('manifest.json', { + chunkModules: false, + source: false, + chunks: false, + modules: false, + assets: true + }) + ] +} + +if (!IS_PRODUCTION) { + config.devServer = { + port: DEV_SERVER_PORT, + headers: { 'Access-Control-Allow-Origin': '*' } + }; + config.output.publicPath = '//localhost:' + DEV_SERVER_PORT + config.output.publicPath; +} + +module.exports = config; |