File tree Expand file tree Collapse file tree 5 files changed +22
-6
lines changed
packages/@vue/cli-service/lib Expand file tree Collapse file tree 5 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,7 @@ module.exports = class Service {
248248 }
249249
250250 // normlaize some options
251+ resolved . baseUrl = resolved . baseUrl . replace ( / ^ \. \/ / , '' )
251252 ensureSlash ( resolved , 'baseUrl' )
252253 removeSlash ( resolved , 'outputDir' )
253254
Original file line number Diff line number Diff line change @@ -24,9 +24,14 @@ module.exports = (api, options) => {
2424 const shadowMode = ! ! process . env . VUE_CLI_CSS_SHADOW_MODE
2525 const isProd = process . env . NODE_ENV === 'production'
2626 const shouldExtract = isProd && extract !== false && ! shadowMode
27+ const filename = getAssetPath (
28+ options ,
29+ `css/[name].[contenthash:8].css` ,
30+ true /* placeAtRootIfRelative */
31+ )
2732 const extractOptions = Object . assign ( {
28- filename : getAssetPath ( options , `css/[name].[contenthash:8].css` ) ,
29- chunkFilename : getAssetPath ( options , 'css/[name].[contenthash:8].css' )
33+ filename,
34+ chunkFilename : filename
3035 } , extract && typeof extract === 'object' ? extract : { } )
3136
3237 // check if the project has a valid postcss config
Original file line number Diff line number Diff line change @@ -2,13 +2,18 @@ module.exports = (api, options) => {
22 api . chainWebpack ( webpackConfig => {
33 if ( process . env . NODE_ENV === 'production' ) {
44 const getAssetPath = require ( '../util/getAssetPath' )
5+ const filename = getAssetPath (
6+ options ,
7+ `js/[name].[chunkhash:8].js` ,
8+ true /* placeAtRootIfRelative */
9+ )
510
611 webpackConfig
712 . mode ( 'production' )
813 . devtool ( 'source-map' )
914 . output
10- . filename ( getAssetPath ( options , `js/[name].[chunkhash:8].js` ) )
11- . chunkFilename ( getAssetPath ( options , `js/[name].[chunkhash:8].js` ) )
15+ . filename ( filename )
16+ . chunkFilename ( filename )
1217
1318 // keep module.id stable when vendor modules does not change
1419 webpackConfig
Original file line number Diff line number Diff line change 11const { createSchema, validate } = require ( '@vue/cli-shared-utils' )
22
33const schema = createSchema ( joi => joi . object ( {
4- baseUrl : joi . string ( ) ,
4+ baseUrl : joi . string ( ) . allow ( '' ) ,
55 outputDir : joi . string ( ) ,
66 assetsDir : joi . string ( ) ,
77 runtimeCompiler : joi . boolean ( ) ,
Original file line number Diff line number Diff line change 11const path = require ( 'path' )
22
3- module . exports = function getAssetPath ( options , filePath ) {
3+ module . exports = function getAssetPath ( options , filePath , placeAtRootIfRelative ) {
4+ // if the user is using a relative URL, place js & css at dist root to ensure
5+ // relative paths work properly
6+ if ( placeAtRootIfRelative && options . baseUrl . charAt ( 0 ) !== '/' ) {
7+ return filePath . replace ( / ^ \w + \/ / , '' )
8+ }
49 return options . assetsDir
510 ? path . posix . join ( options . assetsDir , filePath )
611 : filePath
You can’t perform that action at this time.
0 commit comments