Created
January 12, 2019 23:20
-
-
Save BiosBoy/0b3258e647a28984d88ebddc270f85c4 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
const createConfig = () => { | |
debug('Creating configuration.'); | |
debug(`Enabling devtools for '${__NODE_ENV__} Mode!'`); | |
const webpackConfig = { | |
mode: __DEV__ ? 'development' : 'production', | |
name: 'client', | |
target: 'web', | |
devtool: stageConfig[__NODE_ENV__].devtool, | |
stats: stageConfig[__NODE_ENV__].stats, | |
module: { | |
rules: [...rules] | |
}, | |
...optimization, | |
resolve: { | |
modules: ['node_modules'], | |
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'] | |
} | |
}; | |
// ------------------------------------ | |
// Entry Points | |
// ------------------------------------ | |
webpackConfig.entry = { | |
app: ['babel-polyfill', path.resolve(__dirname, 'src/index.js')].concat( | |
'webpack-hot-middleware/client?path=/__webpack_hmr' | |
) | |
}; | |
// ------------------------------------ | |
// Bundle externals | |
// ------------------------------------ | |
webpackConfig.externals = { | |
react: 'React', | |
'react-dom': 'ReactDOM' | |
}; | |
// ------------------------------------ | |
// Bundle Output | |
// ------------------------------------ | |
webpackConfig.output = { | |
filename: '[name].[hash].js', | |
chunkFilename: '[name].[hash].js', | |
path: path.resolve(__dirname, 'dist'), | |
publicPath: '/' | |
}; | |
// ------------------------------------ | |
// Plugins | |
// ------------------------------------ | |
debug(`Enable plugins for '${__NODE_ENV__} Mode!'`); | |
webpackConfig.plugins = [ | |
new webpack.DefinePlugin({ | |
__DEV__, | |
__PROD__, | |
__TEST__ | |
}), | |
...stagePlugins[__NODE_ENV__] | |
]; | |
// ------------------------------------ | |
// Finishing the Webpack configuration! | |
// ------------------------------------ | |
debug(`Webpack Bundles is Ready for '${__NODE_ENV__} Mode!'`); | |
return webpackConfig; | |
}; | |
module.exports = createConfig(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment