Skip to content

Instantly share code, notes, and snippets.

@stackdumper
Created March 4, 2018 09:13
Show Gist options
  • Save stackdumper/25f3f490ecd4e34a0e8e862e3a855c2d to your computer and use it in GitHub Desktop.
Save stackdumper/25f3f490ecd4e34a0e8e862e3a855c2d to your computer and use it in GitHub Desktop.
Webpack config for React + Styled Components
const webpack = require('webpack');
const path = require('path');
const config = {
entry: [
'babel-polyfill', './src/index'
],
output: {
path: path.join(__dirname, 'bundle'),
filename: 'bundle.js'
},
target: 'electron-renderer',
devtool: 'cheap-module-source-map',
module: {
loaders: [
{
test: /.jsx?$/,
exclude: /\/node_modules\//,
loaders: ['babel-loader']
}, {
test: /.css$/,
loaders: ['style-loader', 'css-loader']
}, {
test: /.less$/,
loaders: [
'style-loader',
'css-loader',
'less-loader'
]
}
]
},
resolve: {
extensions: ['.js', '.jsx', '.less']
},
plugins: [],
};
if (process.env.NODE_ENV === 'production') {
config.plugins.push(new webpack.DefinePlugin({'process.env.NODE_ENV': '"production"'}));
}
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment