From d1c93bd4353ce890a5f67756c0df17550eb58756 Mon Sep 17 00:00:00 2001
From: qlin <haizekuo@gmail.com>
Date: Thu, 3 Mar 2022 21:45:51 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20windicss=20?=
 =?UTF-8?q?=E9=85=8D=E7=BD=AE=20(#104)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: joyzhan <joyzhan@webank.com>
---
 packages/fes-plugin-windicss/src/index.js    | 14 +++++++++++---
 packages/fes-plugin-windicss/windi.config.js |  8 --------
 packages/fes-template-h5/.fes.js             | 11 +++++++++++
 packages/fes-template-h5/src/pages/index.vue |  2 +-
 4 files changed, 23 insertions(+), 12 deletions(-)
 delete mode 100644 packages/fes-plugin-windicss/windi.config.js

diff --git a/packages/fes-plugin-windicss/src/index.js b/packages/fes-plugin-windicss/src/index.js
index ee6c8311..111fc005 100644
--- a/packages/fes-plugin-windicss/src/index.js
+++ b/packages/fes-plugin-windicss/src/index.js
@@ -1,6 +1,5 @@
 
 import WindiCSSWebpackPlugin from 'windicss-webpack-plugin';
-import { resolve } from 'path';
 
 export default (api) => {
     api.describe({
@@ -16,10 +15,19 @@ export default (api) => {
     api.addEntryImportsAhead(() => [{ source: 'windi-base.css' }, { source: 'windi-components.css' }, { source: 'windi-utilities.css' }]);
 
     api.chainWebpack((memo, { createCSSRule }) => {
+        const { config, ...otherOption } = api.config.windicss;
         memo.plugin('windicss').use(WindiCSSWebpackPlugin, [
             {
-                config: resolve(__dirname, '../windi.config.js'),
-                ...api.config.windicss
+                config: {
+                    extract: {
+                        // A common use case is scanning files from the root directory
+                        include: ['**/*.{vue,jsx,js,ts,tsx}'],
+                        // if you are excluding files, make sure you always include node_modules and .git
+                        exclude: ['node_modules', '.git', 'dist']
+                    },
+                    ...config
+                },
+                ...otherOption
             }
         ]);
         if (api.env === 'development') {
diff --git a/packages/fes-plugin-windicss/windi.config.js b/packages/fes-plugin-windicss/windi.config.js
deleted file mode 100644
index 7436c3ab..00000000
--- a/packages/fes-plugin-windicss/windi.config.js
+++ /dev/null
@@ -1,8 +0,0 @@
-export default {
-    extract: {
-        // A common use case is scanning files from the root directory
-        include: ['**/*.{vue,jsx,js,ts,tsx}'],
-        // if you are excluding files, make sure you always include node_modules and .git
-        exclude: ['node_modules', '.git', 'dist']
-    }
-};
diff --git a/packages/fes-template-h5/.fes.js b/packages/fes-template-h5/.fes.js
index b5b8d4ea..75345982 100644
--- a/packages/fes-template-h5/.fes.js
+++ b/packages/fes-template-h5/.fes.js
@@ -34,5 +34,16 @@ export default {
     ],
     devServer: {
         port: 8000
+    },
+    windicss: {
+        config: {
+            theme: {
+                extend: {
+                    colors: {
+                        green: '#7cb305'
+                    }
+                }
+            }
+        }
     }
 };
diff --git a/packages/fes-template-h5/src/pages/index.vue b/packages/fes-template-h5/src/pages/index.vue
index 88138fc6..8cf4ebc3 100644
--- a/packages/fes-template-h5/src/pages/index.vue
+++ b/packages/fes-template-h5/src/pages/index.vue
@@ -1,5 +1,5 @@
 <template>
-    <div class="onepiece m-10px">
+    <div class="onepiece m-10px text-green">
         fes h5 & 拉夫德鲁<br />
         <fes-icon :spin="true" class="one-icon" type="smile" @click="clickIcon" />
         <HelloWorld />