Browse Source

fix iview loader

Michael Wang 6 years ago
parent
commit
53a7baf1d9
4 changed files with 47 additions and 7 deletions
  1. 1 1
      package.json
  2. 3 6
      src/plugins/iview.js
  3. 36 0
      vue.config.js
  4. 7 0
      yarn.lock

+ 1 - 1
package.json

@@ -3,7 +3,6 @@
   "version": "0.3.0-dev",
   "private": true,
   "scripts": {
-    "start": "vue-cli-service serve",
     "serve": "vue-cli-service serve",
     "build": "vue-cli-service build",
     "lint": "vue-cli-service lint",
@@ -34,6 +33,7 @@
     "babel-plugin-import": "^1.11.0",
     "eslint": "^5.8.0",
     "eslint-plugin-vue": "^5.1.0",
+    "iview-loader": "^1.2.2",
     "node-sass": "^4.9.0",
     "sass-loader": "^7.0.1",
     "vue-cli-plugin-axios": "0.0.4",

+ 3 - 6
src/plugins/iview.js

@@ -1,7 +1,7 @@
 import Vue from "vue";
-// import iView from "iview";
+import "iview/dist/styles/iview.css";
+import { Button, Form, FormItem, Input, Icon, Message, Notice } from "iview";
 
-import { Button, Form, FormItem, Input, Icon, Message } from "iview";
 Vue.component("Button", Button);
 Vue.component("Form", Form);
 Vue.component("FormItem", FormItem);
@@ -10,7 +10,4 @@ Vue.component("Icon", Icon);
 Vue.component("Message", Message);
 
 Vue.prototype.$Message = Message;
-
-// Vue.use(iView);
-
-import "iview/dist/styles/iview.css";
+Vue.prototype.$Notice = Notice;

+ 36 - 0
vue.config.js

@@ -0,0 +1,36 @@
+let proxy = {
+  "/ocean/api": {
+    target: "http://192.168.10.30:10060",
+    changeOrigin: true
+  },
+  "/skynet/api": {
+    target: "http://192.168.10.39:8030",
+    changeOrigin: true
+  }
+};
+
+var webpack = require("webpack");
+module.exports = {
+  devServer: {
+    proxy
+  },
+  chainWebpack: config => {
+    // iview Loader
+    config.module
+      .rule("vue")
+      .test(/\.vue$/)
+      .use("iview-loader")
+      .loader("iview-loader")
+      .options({
+        prefix: true
+      })
+      .end();
+  },
+  configureWebpack: {
+    plugins: [
+      // Ignore all locale files of moment.js
+      // TODO: use webpack stats to check if iview locale matters
+      new webpack.IgnorePlugin(/^\.\/locale$/, /moment|iview$/)
+    ]
+  }
+};

+ 7 - 0
yarn.lock

@@ -5447,6 +5447,13 @@ istanbul-reports@^1.5.1:
   dependencies:
     handlebars "^4.0.3"
 
+iview-loader@^1.2.2:
+  version "1.2.2"
+  resolved "https://registry.yarnpkg.com/iview-loader/-/iview-loader-1.2.2.tgz#abdf52074de93c82ef01a2c293deb82c8cbbbde0"
+  integrity sha512-mfnLOsaGcsb570G4Aa9WX7rPle+tNkBEApaCSxUrqtOI6aXBkkETO9rUrbrV0CjH96XQY3AntqSWnNvDw6M+RQ==
+  dependencies:
+    loader-utils "^1.1.0"
+
 iview@^3.2.2:
   version "3.2.2"
   resolved "https://registry.yarnpkg.com/iview/-/iview-3.2.2.tgz#5b7d8db5d1ea711cc39faae60457aa0354cb52c8"