Created
February 20, 2017 15:20
-
-
Save psamim/2235898783908d39bc68e05452af256d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* eslint-disable max-len */ | |
/** | |
* Build config for development process that uses Hot-Module-Replacement | |
* https://webpack.github.io/docs/hot-module-replacement-with-webpack.html | |
*/ | |
import webpack from 'webpack'; | |
import validate, { Joi } from 'webpack-validator'; | |
import merge from 'webpack-merge'; | |
import ExtractTextPlugin from 'extract-text-webpack-plugin'; | |
import cssnext from 'postcss-cssnext'; | |
import baseConfig from './webpack.config.base'; | |
const port = process.env.PORT || 3000; | |
const schemaExtension = Joi.object({ | |
sassLoader: Joi.any(), | |
}); | |
export default validate(merge(baseConfig, { | |
debug: true, | |
devtool: 'inline-source-map', | |
entry: [ | |
`webpack-hot-middleware/client?path=http://localhost:${port}/__webpack_hmr`, | |
'babel-polyfill', | |
'./app/index' | |
], | |
output: { | |
publicPath: `http://localhost:${port}/dist/` | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.global\.css$/, | |
loaders: [ | |
'style-loader', | |
'css-loader?sourceMap' | |
] | |
}, | |
{ | |
test: /^((?!\.global).)*\.css$/, | |
loaders: [ | |
'style-loader', | |
'css-loader?modules&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]', | |
] | |
}, | |
{ | |
test: /(\.scss|\.css)$/, | |
loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!') | |
}, | |
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff' }, | |
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff' }, | |
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/octet-stream' }, | |
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file' }, | |
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=image/svg+xml' }, | |
{ | |
test: /\.(?:ico|gif|png|jpg|jpeg|webp)$/, | |
loader: 'url-loader' | |
} | |
] | |
}, | |
postcss: () => [cssnext()], | |
plugins: [ | |
new ExtractTextPlugin('bundle.css', { allChunks: true }), | |
// https://webpack.github.io/docs/hot-module-replacement-with-webpack.html | |
new webpack.HotModuleReplacementPlugin(), | |
/** | |
* If you are using the CLI, the webpack process will not exit with an error | |
* code by enabling this plugin. | |
* https://github.com/webpack/docs/wiki/list-of-plugins#noerrorsplugin | |
*/ | |
new webpack.NoErrorsPlugin(), | |
/** | |
* Create global constants which can be configured at compile time. | |
* | |
* Useful for allowing different behaviour between development builds and | |
* release builds | |
* | |
* NODE_ENV should be production so that modules do not perform certain | |
* development checks | |
*/ | |
new webpack.DefinePlugin({ | |
'process.env.NODE_ENV': JSON.stringify('development') | |
}) | |
], | |
/** | |
* https://github.com/chentsulin/webpack-target-electron-renderer#how-this-module-works | |
*/ | |
target: 'electron-renderer' | |
}), { schemaExtension }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment