fix: fix extracted css publicPath for target --lib

close #2260
This commit is contained in:
Evan You
2018-08-17 10:04:17 -04:00
parent b1f3a4caa7
commit 1973e2de2c
2 changed files with 9 additions and 9 deletions

View File

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

View File

@@ -33,12 +33,15 @@ module.exports = (api, options) => {
}, extract && typeof extract === 'object' ? extract : {})
// use relative publicPath in extracted CSS based on extract location
const cssPublicPath = '../'.repeat(
extractOptions.filename
.replace(/^\.[\/\\]/, '')
.split(/[\/\\]/g)
.length - 1
)
const cssPublicPath = process.env.VUE_CLI_BUILD_TARGET === 'lib'
// in lib mode, CSS is extracted to dist root.
? './'
: '../'.repeat(
extractOptions.filename
.replace(/^\.[\/\\]/, '')
.split(/[\/\\]/g)
.length - 1
)
// check if the project has a valid postcss config
// if it doesn't, don't use postcss-loader for direct style imports