Skip to content

Commit

Permalink
build: fix rollup config
Browse files Browse the repository at this point in the history
  • Loading branch information
moyus committed Mar 8, 2019
1 parent cf6f477 commit 1c8949f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
7 changes: 5 additions & 2 deletions build/rollup/build-component.rollup.js
Expand Up @@ -42,7 +42,10 @@ function compileVueStylus (content, cb, compiler, filePath) {
if (err) {
throw err
}
const {plugins} = await findPostcssConfig()
const {plugins} = await findPostcssConfig({
env: process.env.NODE_ENV
})

postcss(plugins)
.process(css, {
from: undefined
Expand Down Expand Up @@ -197,4 +200,4 @@ function main() {
})
}

main()
main()
4 changes: 3 additions & 1 deletion build/rollup/rollup-plugin-config.js
Expand Up @@ -62,7 +62,9 @@ async function vueWarpper() {
const {
options,
plugins,
} = await findPostcssConfig({})
} = await findPostcssConfig({
env: process.env.NODE_ENV
})
return [
css({
output: path.resolve(distDir, fileName)
Expand Down
12 changes: 10 additions & 2 deletions build/rollup/rollup-plugin-example-config.js
@@ -1,5 +1,6 @@

const path = require('path')
const fs = require('fs')
const aliasPlugin = require('rollup-plugin-alias')
const replacePlugin = require('rollup-plugin-replace')
const jsonPlugin = require('rollup-plugin-json')
Expand Down Expand Up @@ -36,10 +37,17 @@ async function vueWarpper() {
const {
options,
plugins,
} = await findPostcssConfig({})
} = await findPostcssConfig({
env: process.env.NODE_ENV
})

return [
css({
output: path.resolve(distDir, fileName)
output(styles) {
setTimeout(function () {
fs.writeFileSync(path.resolve(distDir, fileName), styles)
}, 0)
}
}),
vuePlugin({
css: false,
Expand Down
15 changes: 11 additions & 4 deletions postcss.config.js
@@ -1,9 +1,8 @@

// https://github.com/michael-ciniawsky/postcss-load-config
const browserslist = require('./package.json').browserslist
module.exports = () => ({
plugins: {
'postcss-pxtorem': process.env.NODE_ENV !== 'production' ? { rootValue: 100, minPixelValue: 2, propWhiteList: [] } : false,
module.exports = () => {
const plugins = {
'postcss-url': {url: 'inline'},
'cssnano': {
preset: ['default', {
Expand All @@ -16,4 +15,12 @@ module.exports = () => ({
},
'autoprefixer': { browsers: browserslist }
}
})

if (process.env.NODE_ENV !== 'production' || process.env.BUILD_TYPE === 'example') {
plugins['postcss-pxtorem'] = { rootValue: 100, minPixelValue: 2, propWhiteList: [] }
}

return {
plugins
}
}

0 comments on commit 1c8949f

Please sign in to comment.