Skip to content

Commit b559005

Browse files
committed
fix: revert postcss-loader order change
The loader used for minification should come first in the rules array (i.e. execute last, as webpack loaders are executed in reverse order).
1 parent 714d12a commit b559005

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

packages/@vue/cli-service/__tests__/css.spec.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,8 @@ test('css.extract', () => {
133133
// does not support mixing config files with loader options.
134134
expect(findLoaders(config2, lang)).toEqual(['vue-style', 'css', 'postcss', 'postcss'].concat(loader))
135135
expect(findOptions(config2, lang, 'css').importLoaders).toBe(3)
136-
// minification loader should be injected after the user-facing postcss-loader
137-
const rule = findRule(config2, lang)
138-
const postcssUse = rule.use.slice().reverse().find(({ loader }) => loader === 'postcss-loader')
139-
expect(postcssUse.options.plugins).toBeTruthy()
136+
// minification loader should be injected before the user-facing postcss-loader
137+
expect(findOptions(config2, lang, 'postcss').plugins).toBeTruthy()
140138
})
141139
})
142140

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,6 @@ module.exports = (api, options) => {
130130
.loader('css-loader')
131131
.options(cssLoaderOptions)
132132

133-
if (hasPostCSSConfig) {
134-
rule
135-
.use('postcss-loader')
136-
.loader('postcss-loader')
137-
.options(Object.assign({ sourceMap }, loaderOptions.postcss))
138-
}
139-
140133
if (needInlineMinification) {
141134
rule
142135
.use('cssnano')
@@ -147,6 +140,13 @@ module.exports = (api, options) => {
147140
})
148141
}
149142

143+
if (hasPostCSSConfig) {
144+
rule
145+
.use('postcss-loader')
146+
.loader('postcss-loader')
147+
.options(Object.assign({ sourceMap }, loaderOptions.postcss))
148+
}
149+
150150
if (loader) {
151151
rule
152152
.use(loader)

0 commit comments

Comments
 (0)