Created
March 9, 2017 11:24
-
-
Save kix/6d4c0f330b3f140ab5007aa55544bc7e to your computer and use it in GitHub Desktop.
This file contains 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
const webpack = require('webpack') | |
const path = require('path') | |
const devBuild = process.env.NODE_ENV !== 'production' | |
const nodeEnv = devBuild ? 'development' : 'production' | |
const config = { | |
entry: { | |
'client-bundle': [ 'babel-polyfill', 'whatwg-fetch', './app/Resources/js/main.js' ], | |
}, | |
output: { | |
path: path.resolve(__dirname, 'web/assets/build/'), | |
filename: 'bundle.js', | |
}, | |
resolve: { | |
extensions: [ '.js', '.jsx' ], | |
}, | |
plugins: [ | |
new webpack.DefinePlugin({ | |
'process.env': { | |
NODE_ENV: JSON.stringify(nodeEnv), | |
}, | |
}), | |
], | |
module: { | |
rules: [ | |
{ test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/ }, | |
{ test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, | |
loader: 'url-loader', | |
options: { limit: 10000, mimetype: 'application/font-woff' } | |
}, | |
{ | |
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, | |
loader: 'url-loader', | |
options: { limit: 10000, mimetype: 'application/octet-stream' } | |
}, | |
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader' }, | |
{ | |
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, | |
loader: 'url-loader', | |
options: { limit: 10000, mimetype: 'image/svg+xml' } | |
}, | |
{ test: /\.jpe?g$/, loader: 'file-loader' } | |
], | |
} | |
} | |
if (devBuild) { | |
console.log('Webpack dev build') | |
config.devtool = '#eval-source-map' | |
} else { | |
config.plugins.push( | |
new webpack.optimize.DedupePlugin() | |
) | |
console.log('Webpack production build') | |
} | |
module.exports = config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment