Skip to content

Commit

Permalink
fix: fix extracted css publicPath for target --lib
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Aug 17, 2018
1 parent b1f3a4c commit 1973e2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 9 additions & 6 deletions packages/@vue/cli-service/lib/config/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1973e2d

Please sign in to comment.