Created
March 4, 2018 09:13
-
-
Save stackdumper/25f3f490ecd4e34a0e8e862e3a855c2d to your computer and use it in GitHub Desktop.
Webpack config for React + Styled Components
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
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