Skip to content

Instantly share code, notes, and snippets.

@ryandrewjohnson
Last active February 16, 2017 02:46
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 ryandrewjohnson/e9942170b35c379857f8fc5981266b6b to your computer and use it in GitHub Desktop.
Save ryandrewjohnson/e9942170b35c379857f8fc5981266b6b to your computer and use it in GitHub Desktop.
// NOTE: This is not a complete config file, just a partial file for example
import webpack from 'webpack';
import { getIfUtils, removeEmpty } from 'webpack-config-utils';
export default env => {
const { ifProd, ifNotProd } = getIfUtils(env);
return {
cache: ifProd(),
// ------------------------------------
// Entry Points
// ------------------------------------
entry: {
app: [
'react-hot-loader/patch',
'babel-polyfill',
'main.tsx'
]
},
// ------------------------------------
// Devtool
// ------------------------------------
devtool: ifProd('source-map', 'source-map'),
// ------------------------------------
// Module
// ------------------------------------
module: {
rules: removeEmpty([
// Css/Sass loader (prod)
ifProd({
test: /\.scss$/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style',
loader: 'css?modules&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass'
})
})
])
},
// ------------------------------------
// Plugins
// ------------------------------------
plugins: removeEmpty([
new ProgressBarPlugin(),
new HtmlWebpackPlugin({
template: resolve(__dirname, 'src/index.html')
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: ifProd('"production"', '"development"')
}
}),
ifProd(new webpack.LoaderOptionsPlugin({
minimize: true,
debug: true
}))
])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment