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 1b70544

Browse filesBrowse files
esiaoyyx990803
authored andcommitted
Allow vue-loader to user PostCSS options as object and custom syntax (vuejs#240)
* Allow vue-loader to user PostCSS options as object and custom syntax like SugarSS * Fix error reported by eslint * Better testing of available options to avoid complain about undefined properties * Allow postcss to use a PostCSS options object * Fix error option is undefined
1 parent b5b8777 commit 1b70544
Copy full SHA for 1b70544

File tree

1 file changed

+13
-1
lines changed
Filter options

1 file changed

+13
-1
lines changed

‎lib/style-rewriter.js

Copy file name to clipboardExpand all lines: lib/style-rewriter.js
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ module.exports = function (css, map) {
4040
var plugins = options.postcss
4141
if (typeof plugins === 'function') {
4242
plugins = plugins.call(this, this)
43+
} else if (typeof options.postcss === 'object' && options.postcss.plugins) {
44+
plugins = options.postcss.plugins
4345
}
4446
plugins = plugins ? plugins.slice() : [] // make sure to copy it
4547

@@ -72,7 +74,8 @@ module.exports = function (css, map) {
7274
this.sourceMap &&
7375
!this.minimize &&
7476
options.cssSourceMap !== false &&
75-
process.env.NODE_ENV !== 'production'
77+
process.env.NODE_ENV !== 'production' &&
78+
!options.postcss.options.map
7679
) {
7780
opts.map = {
7881
inline: false,
@@ -81,6 +84,15 @@ module.exports = function (css, map) {
8184
}
8285
}
8386

87+
// postcss options from configuration
88+
if (options.postcss && options.postcss.options) {
89+
for (var option in options.postcss.options) {
90+
if (!opts.hasOwnProperty(option)) {
91+
opts[option] = options.postcss.options[option]
92+
}
93+
}
94+
}
95+
8496
postcss(plugins)
8597
.process(css, opts)
8698
.then(function (result) {

0 commit comments

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