Skip to content
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
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/lib/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ module.exports = class Service {
resovledFrom = 'inline options'
}

// normlaize some options
// normalize some options
if (typeof resolved.baseUrl === 'string') {
resolved.baseUrl = resolved.baseUrl.replace(/^\.\//, '')
}
Expand Down
20 changes: 16 additions & 4 deletions packages/@vue/cli-service/lib/config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ module.exports = (api, options) => {
.loader('url-loader')
.options({
limit: inlineLimit,
name: getAssetPath(options, `img/[name].[hash:8].[ext]`)
name: getAssetPath(
options,
`img/[name]${options.filenameHashing ? '.[hash:8]' : ''}.[ext]`
)
})

// do not base64-inline SVGs.
Expand All @@ -93,7 +96,10 @@ module.exports = (api, options) => {
.use('file-loader')
.loader('file-loader')
.options({
name: getAssetPath(options, `img/[name].[hash:8].[ext]`)
name: getAssetPath(
options,
`img/[name]${options.filenameHashing ? '.[hash:8]' : ''}.[ext]`
)
})

webpackConfig.module
Expand All @@ -103,7 +109,10 @@ module.exports = (api, options) => {
.loader('url-loader')
.options({
limit: inlineLimit,
name: getAssetPath(options, `media/[name].[hash:8].[ext]`)
name: getAssetPath(
options,
`media/[name]${options.filenameHashing ? '.[hash:8]' : ''}.[ext]`
)
})

webpackConfig.module
Expand All @@ -113,7 +122,10 @@ module.exports = (api, options) => {
.loader('url-loader')
.options({
limit: inlineLimit,
name: getAssetPath(options, `fonts/[name].[hash:8].[ext]`)
name: getAssetPath(
options,
`fonts/[name]${options.filenameHashing ? '.[hash:8]' : ''}.[ext]`
)
})

// Other common pre-processors ---------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/lib/config/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = (api, options) => {
const shouldExtract = isProd && extract !== false && !shadowMode
const filename = getAssetPath(
options,
`css/[name].[contenthash:8].css`,
`css/[name]${options.filenameHashing ? '.[contenthash:8]' : ''}.css`,
true /* placeAtRootIfRelative */
)
const extractOptions = Object.assign({
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/lib/config/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = (api, options) => {
const getAssetPath = require('../util/getAssetPath')
const filename = getAssetPath(
options,
`js/[name]${isLegacyBundle ? `-legacy` : ``}.[chunkhash:8].js`
`js/[name]${isLegacyBundle ? `-legacy` : ``}${options.filenameHashing ? '.[chunkhash:8]' : ''}.js`
)

webpackConfig
Expand Down
4 changes: 4 additions & 0 deletions packages/@vue/cli-service/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { createSchema, validate } = require('@vue/cli-shared-utils')
const schema = createSchema(joi => joi.object({
baseUrl: joi.string().allow(''),
outputDir: joi.string(),
filenameHashing: joi.boolean(),
assetsDir: joi.string(),
indexPath: joi.string(),
runtimeCompiler: joi.boolean(),
Expand Down Expand Up @@ -53,6 +54,9 @@ exports.defaults = () => ({
// where to output built files
outputDir: 'dist',

// whether filename will contain hash part
filenameHashing: true,

// where to put static assets (js/css/img/font/...)
assetsDir: '',

Expand Down