Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
upgrade webpack from 3.10 to 4.6. update configs to webpack 4. (#140)
Browse files Browse the repository at this point in the history
* upgrade webpack from 3.10 to 4.6.  update configs to webpack 4. now analyze bundles when running locally

* webpack4 replaces namedmodulesplugin w optimization.namedmodules

* changed path to match others in file
  • Loading branch information
RedSquirrelious committed Apr 18, 2018
1 parent 8c4d5dc commit 4078c51
Show file tree
Hide file tree
Showing 6 changed files with 2,920 additions and 958 deletions.
4 changes: 4 additions & 0 deletions cfg/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const siaRoot = path.join(__dirname, '..')
const publicPath = '/assets/'

const config = {
mode: 'development',
entry: {
app: ['babel-polyfill'],
appInsights: path.join(siaRoot, 'src/appInsights')
Expand Down Expand Up @@ -77,6 +78,9 @@ const config = {
}
]
},
optimization: {
noEmitOnErrors: true
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': `"${env}"`,
Expand Down
4 changes: 1 addition & 3 deletions cfg/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ config.entry.app.push(...[
])

config.plugins.push(...[
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.NoEmitOnErrorsPlugin()
new webpack.HotModuleReplacementPlugin()
])

module.exports = config
39 changes: 21 additions & 18 deletions cfg/dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,45 @@ const webpack = require('webpack')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')

const baseConfig = require('./base')
const siaRoot = path.join(__dirname, '..')

const config = Object.assign({}, baseConfig, {
mode: 'production',
cache: false,
devtool: 'sourcemap',
optimization: {
minimizer: [new UglifyJSPlugin({ sourceMap: true })]
},
resolve: {
modules: [
path.resolve(__dirname, '..', 'node_modules')
path.resolve(siaRoot, 'node_modules')
],
alias: {
src: path.resolve(path.join(__dirname, '..', 'src')),
actions: path.resolve(path.join(__dirname, '..', 'src', 'actions')),
components: path.resolve(path.join(__dirname, '..', 'src', 'components')),
config: path.resolve(path.join(__dirname, '..', 'src', 'config')),
containers: path.resolve(path.join(__dirname, '..', 'src', 'containers')),
extensionHooks: path.resolve(path.join(__dirname, '..', 'src', 'extensionHooks')),
helpers: path.resolve(path.join(__dirname, '..', 'src', 'helpers')),
reducers: path.resolve(path.join(__dirname, '..', 'src', 'reducers')),
services: path.resolve(path.join(__dirname, '..', 'src', 'services')),
static: path.resolve(path.join(__dirname, '..', 'src', 'static')),
styles: path.resolve(path.join(__dirname, '..', 'src', 'styles')),
configureStore: path.resolve(path.join(__dirname, '..', 'src', 'configureStore'))
src: path.resolve(path.join(siaRoot, 'src')),
actions: path.resolve(path.join(siaRoot, 'src', 'actions')),
components: path.resolve(path.join(siaRoot, 'src', 'components')),
config: path.resolve(path.join(siaRoot, 'src', 'config')),
containers: path.resolve(path.join(siaRoot, 'src', 'containers')),
extensionHooks: path.resolve(path.join(siaRoot, 'src', 'extensionHooks')),
helpers: path.resolve(path.join(siaRoot, 'src', 'helpers')),
reducers: path.resolve(path.join(siaRoot, 'src', 'reducers')),
services: path.resolve(path.join(siaRoot, 'src', 'services')),
static: path.resolve(path.join(siaRoot, 'src', 'static')),
styles: path.resolve(path.join(siaRoot, 'src', 'styles')),
configureStore: path.resolve(path.join(siaRoot, 'src', 'configureStore'))
}
},
resolveLoader: {
modules: [
path.resolve(path.join(__dirname, '..', 'node_modules'))
path.resolve(path.join(siaRoot, 'node_modules'))
]
}
})

config.entry.app.push(path.join(__dirname, '../src/index'))
config.entry.app.push(path.join(siaRoot, 'src', 'index'))

config.plugins.push(...[
new UglifyJSPlugin({ sourceMap: true }),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.NoEmitOnErrorsPlugin()
new webpack.optimize.AggressiveMergingPlugin()
])

module.exports = config
5 changes: 2 additions & 3 deletions cfg/localhost.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path')
const webpack = require('webpack')

const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const baseConfig = require('./base')

const config = Object.assign({}, baseConfig, {
Expand All @@ -16,8 +16,7 @@ config.entry.app.push(...[

config.plugins.push(...[
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.NoEmitOnErrorsPlugin()
new BundleAnalyzerPlugin()
])

module.exports = config

0 comments on commit 4078c51

Please sign in to comment.