Browse Source

配置webpack&babel

tangjinzhou 6 years ago
parent
commit
897389a702
5 changed files with 19 additions and 1 deletions
  1. 4 1
      babel.config.js
  2. 10 0
      package-lock.json
  3. 1 0
      package.json
  4. 1 0
      src/App.vue
  5. 3 0
      src/main.js

+ 4 - 1
babel.config.js

@@ -1,3 +1,6 @@
 module.exports = {
-  presets: ["@vue/app"]
+  presets: ["@vue/app"],
+  plugins: [
+    ["import", { libraryName: "ant-design-vue", style: true }] // `style: true` 会加载 less 文件
+  ]
 };

+ 10 - 0
package-lock.json

@@ -2286,6 +2286,16 @@
         "object.assign": "^4.1.0"
       }
     },
+    "babel-plugin-import": {
+      "version": "1.11.0",
+      "resolved": "https://registry.npmjs.org/babel-plugin-import/-/babel-plugin-import-1.11.0.tgz",
+      "integrity": "sha512-de9dWdU1YjmWRPYurlHRKD2hTd24z0bIQ0/JgyXqLMXML+TsvEkVhtqzOsNtu9MmCuvwBiTTTjZBbZXA1Xu7TQ==",
+      "dev": true,
+      "requires": {
+        "@babel/helper-module-imports": "^7.0.0",
+        "@babel/runtime": "^7.0.0"
+      }
+    },
     "babel-plugin-istanbul": {
       "version": "4.1.6",
       "resolved": "http://registry.npm.taobao.org/babel-plugin-istanbul/download/babel-plugin-istanbul-4.1.6.tgz",

+ 1 - 0
package.json

@@ -25,6 +25,7 @@
     "babel-core": "7.0.0-bridge.0",
     "babel-eslint": "^10.0.1",
     "babel-jest": "^23.6.0",
+    "babel-plugin-import": "^1.11.0",
     "eslint": "^5.8.0",
     "eslint-plugin-vue": "^5.0.0",
     "less": "^3.0.4",

+ 1 - 0
src/App.vue

@@ -1,6 +1,7 @@
 <template>
   <div id="app">
     <div id="nav">
+      <a-button>hello world</a-button>
       <router-link to="/">Home</router-link> |
       <router-link to="/about">About</router-link>
     </div>

+ 3 - 0
src/main.js

@@ -1,10 +1,13 @@
 import Vue from "vue";
+import { Button } from "ant-design-vue";
 import App from "./App.vue";
 import router from "./router";
 import store from "./store";
 
 Vue.config.productionTip = false;
 
+Vue.use(Button);
+
 new Vue({
   router,
   store,