Skip to content

Commit 94d374b

Browse files
committed
feat: support configuring postcss config root path
1 parent 60d7dcd commit 94d374b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/style-compiler/load-postcss-config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = function loadPostcssConfig (loaderContext, inlineConfig) {
1010
if (process.env.VUE_LOADER_TEST || !loaded) {
1111
loaded = load(
1212
{ webpack: loaderContext },
13-
null,
13+
isObject(inlineConfig) && inlineConfig.configRoot,
1414
{ argv: false }
1515
).catch(() => {
1616
// postcss-load-config throws error when no config file is found,

test/test.js

+18
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,24 @@ describe('vue-loader', function () {
481481
})
482482
})
483483

484+
it('load postcss config file by path', done => {
485+
fs.writeFileSync('test/.postcssrc', JSON.stringify({ parser: 'sugarss' }))
486+
test({
487+
entry: './test/fixtures/postcss.vue',
488+
vue: {
489+
postcss: {
490+
configRoot: path.resolve('test')
491+
}
492+
}
493+
}, (window) => {
494+
var style = window.document.querySelector('style').textContent
495+
style = normalizeNewline(style)
496+
expect(style).to.contain('h1 {\n color: red;\n font-size: 14px\n}')
497+
fs.unlinkSync('test/.postcssrc')
498+
done()
499+
})
500+
})
501+
484502
it('transpile ES2015 features in template', done => {
485503
test({
486504
entry: './test/fixtures/es2015.vue'

0 commit comments

Comments
 (0)