Skip to content

Allow vue-loader to user PostCSS options as object and custom syntax #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 25, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/style-rewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ module.exports = function (css, map) {
var plugins = options.postcss
if (typeof plugins === 'function') {
plugins = plugins.call(this, this)
} else if (typeof options.postcss === 'object' && options.postcss.plugins) {
plugins = options.postcss.plugins
}
plugins = plugins ? plugins.slice() : [] // make sure to copy it

Expand Down Expand Up @@ -72,7 +74,8 @@ module.exports = function (css, map) {
this.sourceMap &&
!this.minimize &&
options.cssSourceMap !== false &&
process.env.NODE_ENV !== 'production'
process.env.NODE_ENV !== 'production' &&
!options.postcss.options.map
) {
opts.map = {
inline: false,
Expand All @@ -81,6 +84,15 @@ module.exports = function (css, map) {
}
}

// postcss options from configuration
if (options.postcss && options.postcss.options) {
for (var option in options.postcss.options) {
if (!opts.hasOwnProperty(option)) {
opts[option] = options.postcss.options[option]
}
}
}

postcss(plugins)
.process(css, opts)
.then(function (result) {
Expand Down