Created
July 10, 2018 21:06
-
-
Save yattias/3afb1235571db9daca5f94e1fc9107fb to your computer and use it in GitHub Desktop.
Sample standard dev config for webpack
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 path = require('path'); | |
const webpack = require('webpack'); | |
const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); | |
const settings = require('./settings'); | |
module.exports = { | |
devtool: 'cheap-module-eval-source-map', | |
entry: [ | |
'./src/client/index' | |
], | |
output: { | |
path: path.join(__dirname, 'dist'), | |
filename: 'bundle.js', | |
publicPath: '/static/' | |
}, | |
watchOptions: { | |
poll: 1000 | |
}, | |
plugins: [ | |
new UglifyJsPlugin({ | |
sourceMap: true | |
}), | |
new webpack.LoaderOptionsPlugin({ | |
debug: true | |
}), | |
/** | |
* NoErrorsPlugin prevents your webpack CLI from exiting with an error code if | |
* there are errors during compiling - essentially, assets that include errors | |
* will not be emitted. If you want your webpack to 'fail', you need to check out | |
* the bail option. | |
*/ | |
new webpack.NoEmitOnErrorsPlugin(), | |
/** | |
* DefinePlugin allows us to define free variables, in any webpack build, you can | |
* use it to create separate builds with debug logging or adding global constants! | |
* Here, we use it to specify a development build. | |
*/ | |
new webpack.DefinePlugin({ | |
'process.env.NODE_ENV': JSON.stringify('development'), | |
'process.env.BUILD_ENV': JSON.stringify(process.env.BUILD_ENV), | |
'__API_HOST__': JSON.stringify(settings.api.host), | |
'__HUB_HOST__': JSON.stringify(settings.hub.host) | |
}) | |
], | |
module: { | |
rules: [ | |
{ | |
test: /\.js?/, | |
include: [ | |
path.join(__dirname, '../../client'), | |
path.join(__dirname, 'config') | |
], | |
exclude: [ | |
/node_modules/, /styles/ | |
], | |
use: [ | |
{ | |
loader: 'babel-loader' | |
} | |
] | |
}, | |
{ | |
test: /\.(jpe?g|png|gif|svg|mov)$/i, | |
loader: 'file-loader?name=[name].[ext]' | |
}, | |
{ | |
test: /\.(scss|css)$/, | |
use: [ | |
'style-loader', | |
'css-loader', | |
'sass-loader' | |
] | |
} | |
] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment