Skip to content

Commit

Permalink
Use hashed assets for all env (#653)
Browse files Browse the repository at this point in the history
* Use hashed assets for all env

* Remove redundant env var

* Disable chunkhash only for hmr
  • Loading branch information
gauravtiwari committed Aug 22, 2017
1 parent 52d1372 commit a331c98
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/install/config/loaders/core/assets.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { env, output } = require('../configuration.js')
const { output } = require('../configuration.js')

module.exports = {
test: /\.(jpg|jpeg|png|gif|svg|eot|ttf|woff|woff2)$/i,
Expand All @@ -7,7 +7,7 @@ module.exports = {
options: {
// Set publicPath with ASSET_HOST env if available so internal assets can use CDN
publicPath: output.publicPathWithHost,
name: env.NODE_ENV === 'production' ? '[name]-[hash].[ext]' : '[name].[ext]'
name: '[name]-[hash].[ext]'
}
}]
}
1 change: 0 additions & 1 deletion lib/install/config/webpack/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const CompressionPlugin = require('compression-webpack-plugin')
const sharedConfig = require('./shared.js')

module.exports = merge(sharedConfig, {
output: { filename: '[name]-[chunkhash].js' },
devtool: 'source-map',
stats: 'normal',

Expand Down
4 changes: 3 additions & 1 deletion lib/install/config/webpack/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const { env, settings, output, loadersDir, resolvedModules } = require('./config
const extensionGlob = `**/*{${settings.extensions.join(',')}}`
const entryPath = join(settings.source_path, settings.source_entry_path)
const packPaths = sync(join(entryPath, extensionGlob))
const isHMR = settings.dev_server && settings.dev_server.hmr

module.exports = {
entry: packPaths.reduce(
Expand All @@ -26,7 +27,8 @@ module.exports = {
),

output: {
filename: '[name].js',
filename: isHMR ? '[name]-[hash].js' : '[name]-[chunkhash].js',
chunkFilename: '[name]-[chunkhash].chunk.js',
path: output.path,
publicPath: output.publicPath
},
Expand Down

0 comments on commit a331c98

Please sign in to comment.