From 128dcbe26694790d569c4addcc3f7afe774193eb Mon Sep 17 00:00:00 2001 From: Clark Du Date: Wed, 15 Aug 2018 15:22:26 +0100 Subject: [PATCH] refactor: add build.postcss.preset config --- lib/builder/webpack/utils/postcss.js | 9 +++++---- lib/common/nuxt.config.js | 7 ++++++- package.json | 1 - test/fixtures/with-config/nuxt.config.js | 10 ++++++++++ yarn.lock | 13 +------------ 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/lib/builder/webpack/utils/postcss.js b/lib/builder/webpack/utils/postcss.js index 31f6ec2055..fd984ce654 100644 --- a/lib/builder/webpack/utils/postcss.js +++ b/lib/builder/webpack/utils/postcss.js @@ -43,10 +43,7 @@ export default class PostcssConfig { 'postcss-url': {}, // https://github.com/csstools/postcss-preset-env - 'postcss-preset-env': { - // https://cssdb.org/#staging-process - stage: 2 - }, + 'postcss-preset-env': this.preset || {}, 'cssnano': this.dev ? false : { preset: 'default' } } } @@ -114,6 +111,10 @@ export default class PostcssConfig { // Apply default plugins if (isPureObject(config)) { + if (config.preset) { + this.preset = config.preset + delete config.preset + } _.defaults(config, this.defaultConfig) this.loadPlugins(config) diff --git a/lib/common/nuxt.config.js b/lib/common/nuxt.config.js index 6545fba8f7..3edfb23b2f 100644 --- a/lib/common/nuxt.config.js +++ b/lib/common/nuxt.config.js @@ -76,7 +76,12 @@ export default { }, transpile: [], // Name of NPM packages to be transpiled vueLoader: {}, - postcss: {}, + postcss: { + preset: { + // https://cssdb.org/#staging-process + stage: 2 + } + }, templates: [], watch: [], devMiddleware: {}, diff --git a/package.json b/package.json index de8806968f..9566917f37 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,6 @@ "@nuxtjs/babel-preset-app": "^0.3.0", "@nuxtjs/friendly-errors-webpack-plugin": "^2.0.2", "@nuxtjs/youch": "^4.2.3", - "autoprefixer": "^8.6.5", "babel-loader": "^8.0.0-beta", "cache-loader": "^1.2.2", "caniuse-lite": "^1.0.30000874", diff --git a/test/fixtures/with-config/nuxt.config.js b/test/fixtures/with-config/nuxt.config.js index 31d2f9c413..6afc93c0af 100644 --- a/test/fixtures/with-config/nuxt.config.js +++ b/test/fixtures/with-config/nuxt.config.js @@ -72,6 +72,16 @@ export default { return Object.assign({}, config, { devtool: 'nosources-source-map' }) + }, + postcss: { + preset: { + features: { + 'custom-selectors': true + }, + autoprefixer: { + grid: true + } + } } }, css: [{ src: '~/assets/app.css' }], diff --git a/yarn.lock b/yarn.lock index 426a36f5af..a0bb0ead4a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1216,17 +1216,6 @@ autoprefixer@^8.5.0: postcss "^6.0.22" postcss-value-parser "^3.2.3" -autoprefixer@^8.6.5: - version "8.6.5" - resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-8.6.5.tgz#343f3d193ed568b3208e00117a1b96eb691d4ee9" - dependencies: - browserslist "^3.2.8" - caniuse-lite "^1.0.30000864" - normalize-range "^0.1.2" - num2fraction "^1.2.2" - postcss "^6.0.23" - postcss-value-parser "^3.2.3" - aws-sign2@~0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" @@ -1725,7 +1714,7 @@ caniuse-api@^3.0.0: lodash.memoize "^4.1.2" lodash.uniq "^4.5.0" -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000864, caniuse-lite@^1.0.30000865, caniuse-lite@^1.0.30000874: +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000865, caniuse-lite@^1.0.30000874: version "1.0.30000874" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000874.tgz#a641b1f1c420d58d9b132920ef6ba87bbdcd2223"