Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7882234

Browse filesBrowse files
committed
properly support sourcemaps in style-rewriter
1 parent 12628f6 commit 7882234
Copy full SHA for 7882234

File tree

Expand file treeCollapse file tree

1 file changed

+25
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+25
-7
lines changed

‎lib/style-rewriter.js

Copy file name to clipboardExpand all lines: lib/style-rewriter.js
+25-7Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,21 @@ var addId = postcss.plugin('add-id', function () {
3030
}
3131
})
3232

33-
module.exports = function (css) {
33+
module.exports = function (css, map) {
3434
this.cacheable()
3535
var cb = this.async()
3636

3737
var query = loaderUtils.parseQuery(this.query)
3838
var options = this.options.vue || {}
3939
var autoprefixOptions = options.autoprefixer
40+
var plugins = []
4041

41-
var processors = []
42+
// scoped css
4243
if (query.scoped) {
43-
processors.push(addId)
44+
plugins.push(addId)
4445
}
46+
47+
// autoprefixer
4548
if (autoprefixOptions !== false) {
4649
autoprefixOptions = assign(
4750
{},
@@ -50,14 +53,29 @@ module.exports = function (css) {
5053
autoprefixOptions
5154
)
5255
var autoprefixer = require('autoprefixer')(autoprefixOptions)
53-
processors.push(autoprefixer)
56+
plugins.push(autoprefixer)
57+
}
58+
59+
// postcss options, for source maps
60+
var file = loaderUtils.getRemainingRequest(this)
61+
var opts
62+
opts = {
63+
from: file,
64+
to: file,
65+
map: {
66+
inline: false,
67+
annotation: false
68+
}
69+
}
70+
if (map) {
71+
opts.map.prev = map
5472
}
5573

5674
currentId = '_v-' + hash(this.resourcePath)
57-
postcss(processors)
58-
.process(css)
75+
postcss(plugins)
76+
.process(css, opts)
5977
.then(function (result) {
60-
cb(null, result)
78+
cb(null, result.css, result.map)
6179
})
6280
.catch(function (e) {
6381
console.log(e)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.