Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b41ed76

Browse filesBrowse files
authored
fix: mini-css-extract-plugin publicPath option can be an absolute path (#6230)
When the user sets the project public path to the absolute path, the extract-css publicPath option should be changed accordingly
1 parent f8017ca commit b41ed76
Copy full SHA for b41ed76

File tree

Expand file treeCollapse file tree

1 file changed

+10
-6
lines changed
Filter options
  • packages/@vue/cli-service/lib/config
Expand file treeCollapse file tree

1 file changed

+10
-6
lines changed

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

Copy file name to clipboardExpand all lines: packages/@vue/cli-service/lib/config/css.js
+10-6Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const fs = require('fs')
22
const path = require('path')
3+
const isAbsoluteUrl = require('../util/isAbsoluteUrl')
34

45
const findExisting = (context, files) => {
56
for (const file of files) {
@@ -39,16 +40,19 @@ module.exports = (api, rootOptions) => {
3940
chunkFilename: filename
4041
}, extract && typeof extract === 'object' ? extract : {})
4142

43+
// when project publicPath is a relative path
4244
// use relative publicPath in extracted CSS based on extract location
43-
const cssPublicPath = process.env.VUE_CLI_BUILD_TARGET === 'lib'
44-
// in lib mode, CSS is extracted to dist root.
45-
? './'
46-
: '../'.repeat(
47-
extractOptions.filename
45+
const cssPublicPath = (isAbsoluteUrl(rootOptions.publicPath) || rootOptions.publicPath.startsWith('/'))
46+
? rootOptions.publicPath
47+
: process.env.VUE_CLI_BUILD_TARGET === 'lib'
48+
// in lib mode, CSS is extracted to dist root.
49+
? './'
50+
: '../'.repeat(
51+
extractOptions.filename
4852
.replace(/^\.[/\\]/, '')
4953
.split(/[/\\]/g)
5054
.length - 1
51-
)
55+
)
5256

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.