Skip to content

Commit 27e3500

Browse files
committed
wip
1 parent f354290 commit 27e3500

File tree

6 files changed

+30
-13
lines changed

6 files changed

+30
-13
lines changed

lib/css-rewriter.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = function (css) {
2+
this.cacheable()
3+
console.log(css)
4+
return css
5+
}

lib/loader.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ module.exports = function (content) {
3434
loaderUtils.stringifyRequest(self,
3535
// disable system loaders (except post loaders)
3636
'-!' +
37-
// check for local CSS rewrite
38-
(part.local ? cssRewriterPath + '!' : '') +
3937
// get loader string for pre-processors
40-
getPreprocessorString(type, part.lang) +
38+
getLoaderString(type, part) +
4139
// select the corresponding part from the vue file
4240
getSelectorString(type, index || 0) +
4341
// the url to the actual vuefile
@@ -50,18 +48,20 @@ module.exports = function (content) {
5048
return 'require(' +
5149
loaderUtils.stringifyRequest(self,
5250
'-!' +
53-
getPreprocessorString(include.type, include.lang) +
51+
getLoaderString(include.type, include) +
5452
include.src
5553
) +
5654
')\n'
5755
}
5856

59-
function getPreprocessorString (type, lang) {
60-
lang = lang || defaultLang[type]
61-
var loader = loaders[lang] !== undefined
62-
? loaders[lang]
63-
: loaderPrefix[type] + lang
64-
return loader ? loader + '!' : ''
57+
function getLoaderString (type, part) {
58+
var lang = part.lang || defaultLang[type]
59+
var localCssString = type === 'style' && part.local
60+
? cssRewriterPath + '!'
61+
: ''
62+
return loaders[lang] !== undefined
63+
? loaders[lang] + '!' + localCssString
64+
: loaderPrefix[type] + localCssString + lang + '!'
6565
}
6666

6767
function getSelectorString (type, index) {

lib/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module.exports = function (content) {
5757
var end = node.childNodes[node.childNodes.length - 1].__location.end
5858
output[type].push({
5959
lang: lang,
60-
local: local,
60+
local: local != null,
6161
content: content.substring(start, end).trim()
6262
})
6363
})

test/fixtures/import.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/fixtures/local-css.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<style local>
2+
h1 { color: red; }
3+
</style>

test/test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,17 @@ describe('vue-loader', function () {
9090

9191
it('import', function (done) {
9292
test({
93-
entry: './test/fixtures/import.js'
93+
entry: './test/fixtures/import.vue'
94+
}, function (window) {
95+
var style = window.document.querySelector('style').textContent
96+
expect(style).to.contain('h1 { color: red; }')
97+
done()
98+
})
99+
})
100+
101+
it('local-css', function (done) {
102+
test({
103+
entry: './test/fixtures/local-css.vue'
94104
}, function (window) {
95105
var style = window.document.querySelector('style').textContent
96106
expect(style).to.contain('h1 { color: red; }')

0 commit comments

Comments
 (0)