Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Adjust hashes used in production asset filenames #930

Merged
merged 1 commit into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/font-loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ neutrino.use(fonts);

// Usage showing default options
neutrino.use(fonts, {
name: neutrino.options.command === 'build' ? '[name].[hash].[ext]' : '[name].[ext]'
name: mode === 'production' ? '[name].[hash:8].[ext]' : '[name].[ext]'
});
```

Expand All @@ -57,7 +57,7 @@ module.exports = {
module.exports = {
use: [
['@neutrinojs/font-loader', {
name: neutrino.options.command === 'build' ? '[name].[hash].[ext]' : '[name].[ext]'
name: mode === 'production' ? '[name].[hash:8].[ext]' : '[name].[ext]'
}]
]
};
Expand Down
2 changes: 1 addition & 1 deletion packages/font-loader/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = (neutrino, options = {}) => {
const isProduction = neutrino.config.get('mode') === 'production';
const defaultOptions = {
name: isProduction ? '[name].[hash].[ext]' : '[name].[ext]'
name: isProduction ? '[name].[hash:8].[ext]' : '[name].[ext]'
};

neutrino.config.module
Expand Down
4 changes: 2 additions & 2 deletions packages/image-loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ neutrino.use(images);
// Usage showing default options
neutrino.use(images, {
limit: 8192,
name: neutrino.options.command === 'build' ? '[name].[hash].[ext]' : '[name].[ext]'
name: mode === 'production' ? '[name].[hash:8].[ext]' : '[name].[ext]'
});
```

Expand All @@ -59,7 +59,7 @@ module.exports = {
use: [
['@neutrinojs/image-loader', {
limit: 8192,
name: neutrino.options.command === 'build' ? '[name].[hash].[ext]' : '[name].[ext]'
name: mode === 'production' ? '[name].[hash:8].[ext]' : '[name].[ext]'
}]
]
};
Expand Down
2 changes: 1 addition & 1 deletion packages/image-loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = (neutrino, options = {}) => {
const isProduction = neutrino.config.get('mode') === 'production';
const defaultOptions = {
limit: 8192,
name: isProduction ? '[name].[hash].[ext]' : '[name].[ext]'
name: isProduction ? '[name].[hash:8].[ext]' : '[name].[ext]'
};

neutrino.config.module
Expand Down
2 changes: 1 addition & 1 deletion packages/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = (neutrino, opts = {}) => {
.path(neutrino.options.output)
.filename('[name].js')
.libraryTarget('commonjs2')
.chunkFilename('[id].[hash:5]-[chunkhash:7].js')
.chunkFilename('[name].js')
.end()
.resolve
.extensions
Expand Down
4 changes: 2 additions & 2 deletions packages/style-loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ neutrino.use(styles, {
extract: {
plugin: {},
loader: {
filename: neutrino.options.command === 'build' ? '[name].[contenthash].css' : '[name].css'
filename: mode === 'production' ? '[name].[contenthash:8].css' : '[name].css'
}
}
});
Expand Down Expand Up @@ -95,7 +95,7 @@ module.exports = {
extract: {
plugin: {},
loader: {
filename: neutrino.options.command === 'build' ? '[name].[contenthash].css' : '[name].css'
filename: mode === 'production' ? '[name].[contenthash:8].css' : '[name].css'
}
}
}]
Expand Down
2 changes: 1 addition & 1 deletion packages/style-loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = (neutrino, opts = {}) => {
loader: {},
plugin: {
filename: neutrino.config.get('mode') === 'production'
? '[name].[contenthash].css'
? '[name].[contenthash:8].css'
: '[name].css'
}
}
Expand Down
14 changes: 7 additions & 7 deletions packages/web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ module.exports = (neutrino, opts = {}) => {
});
});

const jsFilename = mode === 'production' ? '[name].[contenthash:8].js' : '[name].js';

neutrino.config
.optimization
.minimize(options.minify.source)
Expand All @@ -145,9 +147,9 @@ module.exports = (neutrino, opts = {}) => {
// https://github.com/webpack/webpack/issues/7064
chunks: 'all',
// By default the generated files use names that reference the chunk names, eg:
// `vendors~index~page2.b694ee990c08e6be6a33.js`. Setting to `false` causes them to
// use the chunk ID instead (eg `1.ceddedc0defa56bec89f.js`), which prevents cache-
// busting when a new page is added with the same shared vendor dependencies.
// `vendors~index~page2.b694ee99.js`. Setting to `false` causes them to use the
// chunk ID instead (eg `1.ceddedc0.js`), which prevents cache-busting when a
// new page is added with the same shared vendor dependencies.
name: mode !== 'production'
})
// Create a separate chunk for the webpack runtime, so it can be cached separately
Expand All @@ -162,8 +164,8 @@ module.exports = (neutrino, opts = {}) => {
.output
.path(neutrino.options.output)
.publicPath(options.publicPath)
.filename('[name].js')
.chunkFilename('[name].[chunkhash].js')
.filename(jsFilename)
.chunkFilename(jsFilename)
.end()
.resolve
.extensions
Expand Down Expand Up @@ -211,7 +213,5 @@ module.exports = (neutrino, opts = {}) => {
neutrino.config.plugin('manifest')
.use(ManifestPlugin, [options.manifest]);
}

config.output.filename('[name].[chunkhash].js');
});
};