Skip to content

Commit d0de715

Browse files
committed
fix css extraction and pre-processors in vue-loader
1 parent 15be241 commit d0de715

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

packages/@vue/cli-service-global/__tests__/globalService.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const entryVue = `
2323
data: () => ({ msg: 'hi' })
2424
}
2525
</script>
26+
<style>
27+
h1 { color: red }
28+
</style>
2629
`.trim()
2730

2831
const entryJs = `
@@ -62,6 +65,7 @@ test('global build', async () => {
6265
const hasFile = file => fs.existsSync(path.join(distDir, file))
6366
expect(hasFile('index.html')).toBe(true)
6467
expect(hasFile('static/js')).toBe(true)
68+
expect(hasFile('static/css')).toBe(true)
6569

6670
const port = await portfinder.getPortPromise()
6771
server = createServer({ root: distDir })

packages/@vue/cli-service-global/lib/createConfigPlugin.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@ module.exports = function createConfigPlugin (context, entry) {
3939
.rule('vue')
4040
.use('vue-loader')
4141
.tap(options => {
42-
return Object.assign({
43-
loaders: {
44-
js: {
45-
loader: 'babel-loader',
46-
options: babelOptions
47-
}
42+
options.loaders = Object.assign({
43+
js: {
44+
loader: 'babel-loader',
45+
options: babelOptions
4846
}
49-
}, options)
47+
}, options.loaders)
48+
return options
5049
})
5150

5251
// set inline babel options

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ test('serve', async () => {
2525
expect(hasFile('index.html')).toBe(true)
2626
expect(hasFile('favicon.ico')).toBe(true)
2727
expect(hasFile('static/js')).toBe(true)
28+
expect(hasFile('static/css')).toBe(true)
2829
expect(hasFile('foo.js')).toBe(true)
2930

3031
const port = await portfinder.getPortPromise()

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ module.exports = (api, options) => {
1919
.tap(options => {
2020
// ensure user injected vueLoaderOptions take higher priority
2121
options.loaders = Object.assign(resolver.vue(), options.loaders)
22+
options.cssSourceMap = !!options.cssSourceMap
23+
return options
2224
})
2325

2426
// apply css loaders for standalone style files outside vue-loader
@@ -70,7 +72,7 @@ module.exports = (api, options) => {
7072
webpackConfig
7173
.plugin('extract-css')
7274
.use(ExtractTextPlugin, [Object.assign({
73-
filename: '[name].[contenthash:8].css',
75+
filename: `${options.staticDir}/css/[name].[contenthash:8].css`,
7476
allChunks: true
7577
}, userOptions)])
7678
}

packages/@vue/cli-service/lib/util/CSSLoaderResolver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ module.exports = class CSSLoaderResolver {
183183
* })
184184
*/
185185
vue (options = {}) {
186-
this.postcssOptions = false
186+
this.postcss = false
187187
this.cssModules = false
188188
const loaders = {}
189189
for (const lang of ['css', 'sass', 'scss', 'less', 'stylus', 'styl']) {

0 commit comments

Comments
 (0)