Skip to content

Instantly share code, notes, and snippets.

@kix
Created March 9, 2017 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kix/6d4c0f330b3f140ab5007aa55544bc7e to your computer and use it in GitHub Desktop.
Save kix/6d4c0f330b3f140ab5007aa55544bc7e to your computer and use it in GitHub Desktop.
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