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 authored Aug 17, 2017
1 parent aaa876f commit bddfb95
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]'

This comment has been minimized.

Copy link
@justin808

justin808 Aug 18, 2017

Contributor

I'm curious as to why we're hashing in development and test, other than to simplify the settings.

This comment has been minimized.

Copy link
@gauravtiwari

gauravtiwari Aug 18, 2017

Author Member

@justin808 For cache-control so the assets don't get cached in development (usually happens when using watcher). Also it follows the same sprockets convention.

}
}]
}
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 bddfb95

Please sign in to comment.