Created
April 14, 2017 00:32
-
-
Save lion19/0c615ebf869327c6627e02f72c082388 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
/** | |
* Build config for electron 'Renderer Process' file | |
*/ | |
import path from 'path'; | |
import webpack from 'webpack'; | |
import validate from 'webpack-validator'; | |
import ExtractTextPlugin from 'extract-text-webpack-plugin'; | |
import merge from 'webpack-merge'; | |
import HtmlWebpackPlugin from 'html-webpack-plugin'; | |
import BabiliPlugin from 'babili-webpack-plugin'; | |
import baseConfig from './webpack.config.base'; | |
export default validate(merge(baseConfig, { | |
devtool: 'cheap-module-source-map', | |
entry: ['babel-polyfill', './app/index'], | |
output: { | |
libraryTarget: 'umd', | |
path: path.join(__dirname, 'app/dist'), | |
publicPath: '../dist/' | |
}, | |
module: { | |
loaders: [ | |
// Extract all .global.css to style.css as is | |
{ | |
test: /\.global\.css$/, | |
loader: ExtractTextPlugin.extract( | |
'style-loader', | |
'css-loader' | |
) | |
}, | |
// Pipe other styles through css modules and append to style.css | |
{ | |
test: /^((?!\.global).)*\.css$/, | |
loader: ExtractTextPlugin.extract( | |
'style-loader', | |
'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]' | |
) | |
}, | |
// Fonts | |
{ 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' }, | |
// Images | |
{ | |
test: /\.(?:ico|gif|png|jpg|jpeg|webp)$/, | |
loader: 'url-loader' | |
} | |
] | |
}, | |
plugins: [ | |
/** | |
* Assign the module and chunk ids by occurrence count | |
* Reduces total file size and is recommended | |
*/ | |
new webpack.optimize.OccurrenceOrderPlugin(), | |
/** | |
* 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('production') | |
}), | |
/** | |
* Babli is an ES6+ aware minifier based on the Babel toolchain (beta) | |
*/ | |
new BabiliPlugin(), | |
new ExtractTextPlugin('style.css', { allChunks: true }), | |
/** | |
* Dynamically generate index.html page | |
*/ | |
new HtmlWebpackPlugin({ | |
filename: './index.html', | |
template: 'app/webapp.html', | |
inject: false | |
}) | |
], | |
// https://github.com/chentsulin/webpack-target-electron-renderer#how-this-module-works | |
target: 'web' | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment