瀏覽代碼

refactor(dev): use cssnano as postcss plugin

Andelf 3 年之前
父節點
當前提交
3958c647e1
共有 2 個文件被更改,包括 5 次插入10 次删除
  1. 4 10
      gulpfile.js
  2. 1 0
      postcss.config.js

+ 4 - 10
gulpfile.js

@@ -23,16 +23,10 @@ const css = {
   },
 
   buildCSS (...params) {
-    return gulp.series(
-      () => exec(`yarn css:build`, {}),
-      css._optimizeCSSForRelease
-    )(...params)
-  },
-
-  _optimizeCSSForRelease () {
-    return gulp.src(path.join(outputPath, 'css', 'style.css'))
-      .pipe(cleanCSS())
-      .pipe(gulp.dest(path.join(outputPath, 'css')))
+    return cp.spawn(`yarn css:build`, {
+      shell: true,
+      stdio: 'inherit'
+    })
   }
 }
 

+ 1 - 0
postcss.config.js

@@ -4,5 +4,6 @@ module.exports = (ctx) => ({
     require('postcss-import-ext-glob')({}),
     require('postcss-import')({}),
     require('tailwindcss')('tailwind.config.js'),
+    ...(process.env.NODE_ENV === 'production' ? [require('cssnano')({})] : [])
   ],
 })