Skip to content

Commit 1973e2d

Browse files
committed
fix: fix extracted css publicPath for target --lib
close vuejs#2260
1 parent b1f3a4c commit 1973e2d

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/@vue/cli-service/lib/commands/build/resolveLibConfig.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ const fs = require('fs')
22
const path = require('path')
33

44
module.exports = (api, { entry, name }, options) => {
5-
// inline all static asset files since there is no publicPath handling
6-
process.env.VUE_CLI_INLINE_LIMIT = Infinity
7-
85
const { log, error } = require('@vue/cli-shared-utils')
96
const abort = msg => {
107
log()

packages/@vue/cli-service/lib/config/css.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ module.exports = (api, options) => {
3333
}, extract && typeof extract === 'object' ? extract : {})
3434

3535
// use relative publicPath in extracted CSS based on extract location
36-
const cssPublicPath = '../'.repeat(
37-
extractOptions.filename
38-
.replace(/^\.[\/\\]/, '')
39-
.split(/[\/\\]/g)
40-
.length - 1
41-
)
36+
const cssPublicPath = process.env.VUE_CLI_BUILD_TARGET === 'lib'
37+
// in lib mode, CSS is extracted to dist root.
38+
? './'
39+
: '../'.repeat(
40+
extractOptions.filename
41+
.replace(/^\.[\/\\]/, '')
42+
.split(/[\/\\]/g)
43+
.length - 1
44+
)
4245

4346
// check if the project has a valid postcss config
4447
// if it doesn't, don't use postcss-loader for direct style imports

0 commit comments

Comments
 (0)