Skip to content

Instantly share code, notes, and snippets.

@phongsakornp
Created March 13, 2017 20:14
Show Gist options
  • Save phongsakornp/c6ea41fa2e901c072f67a4b477981b77 to your computer and use it in GitHub Desktop.
Save phongsakornp/c6ea41fa2e901c072f67a4b477981b77 to your computer and use it in GitHub Desktop.
Electron Webpack Config
const path = require('path')
const webpack = require('webpack')
const PATHS = {
app: path.join(__dirname, 'src/app/index'),
build: path.join(__dirname, 'build')
}
let options = {
target: 'electron',
entry: {
app: PATHS.app
},
output: {
path: PATHS.build,
filename: 'bundle.js',
publicPath: 'http://localhost:8080/build/'
},
module: {
//https://github.com/webpack/webpack/issues/1617
noParse: [
/node_modules\/handsontable\/dist\/handsontable.js/,
/node_modules\/paper\/dist\/paper-full.min.js/
],
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['react', 'es2015', 'stage-0']
}
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file'
},
{
test: /\.(woff|woff2)$/,
loader:'url?prefix=font/&limit=5000'
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/octet-stream'
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=image/svg+xml'
},
{
// https://github.com/webpack-contrib/css-loader/issues/38#issuecomment-72287584
// Fix error parse failed in semantic-ui-css `png` loader.
// test: /\.(png|woff|woff2|eot|ttf|svg)$/,
test: /\.(png)$/,
loader: 'url-loader?limit=100000'
},
{
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader'
}
]
},
externals: {
// put your node 3rd party libraries which can't be built with webpack here
// (mysql, mongodb, and so on..)
},
plugins: [
new webpack.ExternalsPlugin('commonjs2', ['leveldown']),
],
resolve: {
modulesDirectories: ['node_modules'],
extensions: ['*', '.js', '.jsx', '.json'],
fallback: path.join(__dirname, 'node_modules'),
alias: {
'paper': 'paper/dist/paper-full.min.js'
}
}
};
module.exports = options;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment