Add build.postcss option

This commit is contained in:
Sébastien Chopin 2016-11-23 00:47:31 +01:00
parent fc598ea66e
commit 57b55dc512
3 changed files with 13 additions and 14 deletions

View File

@ -43,7 +43,8 @@ const defaults = {
vendor: [],
loaders: [],
plugins: [],
babel: {}
babel: {},
postcss: []
}
const defaultsLoaders = [
{
@ -63,14 +64,18 @@ const defaultsLoaders = [
}
}
]
const defaultsPostcss = [
require('autoprefixer')({
browsers: ['last 3 versions']
})
]
module.exports = function * () {
// Defaults build options
if (this.options.build && Array.isArray(this.options.build.loaders)) {
this.options.build = _.defaultsDeep(this.options.build, defaults)
} else {
this.options.build = _.defaultsDeep(this.options.build, defaults, { loaders: defaultsLoaders })
}
let extraDefaults = {}
if (this.options.build && !Array.isArray(this.options.build.loaders)) extraDefaults.loaders = defaultsLoaders
if (this.options.build && !Array.isArray(this.options.build.postcss)) extraDefaults.postcss = defaultsPostcss
this.options.build = _.defaultsDeep(this.options.build, defaults, extraDefaults)
if (!this.options._build && !this.options._renderer) {
return Promise.resolve()
}

View File

@ -2,11 +2,7 @@
module.exports = function () {
let config = {
postcss: [
require('autoprefixer')({
browsers: ['last 3 versions']
})
],
postcss: this.options.build.postcss,
loaders: {
'js': 'babel-loader?presets[]=es2015&presets[]=stage-2',
'postcss': 'vue-style-loader!css-loader',

View File

@ -1,6 +1,6 @@
{
"name": "nuxt",
"version": "0.6.6",
"version": "0.6.7",
"description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)",
"main": "index.js",
"license": "MIT",
@ -9,8 +9,6 @@
"nuxt": "./bin/nuxt"
},
"scripts": {
"start": "DEBUG=nuxt:* bin/nuxt",
"dev": "DEBUG=nuxt:* nodemon bin/nuxt",
"test": "npm run lint",
"lint": "eslint --ext .js,.vue bin lib pages test index.js --ignore-pattern lib/app",
"precommit": "npm run lint"