├── .env ├── .env.development ├── .env.stage ├── .gitignore ├── README.md ├── babel.config.js ├── package.json ├── public ├── favicon.ico └── index.html ├── src ├── App.vue ├── assets │ └── logo.png ├── components │ ├── hello │ │ ├── index.js │ │ └── src │ │ │ └── index.vue │ ├── mixin.js │ └── sample │ │ ├── index.js │ │ ├── src │ │ └── index.vue │ │ └── style.less ├── i18n │ ├── zh-CN.js │ └── zh-TW.js ├── main.js ├── modules │ ├── about.js │ └── home.js ├── registry │ ├── components.js │ ├── i18n.js │ ├── index.js │ ├── modules.js │ ├── router.js │ └── store.js ├── sheet │ ├── skin │ │ ├── ant-design.less │ │ └── element-ui.scss │ └── variable │ │ ├── colour.less │ │ ├── family.less │ │ ├── index.less │ │ ├── preset.less │ │ ├── size.less │ │ ├── space.less │ │ └── speed.less ├── utils │ ├── exceptor.js │ ├── index.js │ ├── interceptor.js │ ├── language.js │ └── log.js └── views │ ├── About.vue │ └── Home.vue └── vue.config.js /.env: -------------------------------------------------------------------------------- 1 | proxy = 'http://zhisiyun.com/' 2 | -------------------------------------------------------------------------------- /.env.development: -------------------------------------------------------------------------------- 1 | proxy = 'http://47.99.112.156/' 2 | -------------------------------------------------------------------------------- /.env.stage: -------------------------------------------------------------------------------- 1 | proxy = 'http://zhisiyun.com/' 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vue Staff 2 | 3 | > Author By Joenix Team 4 | 5 | ## Get Start 6 | 7 | ```bash 8 | yarn 9 | # or 10 | npm i 11 | ``` 12 | 13 | ### Compiles and Hot-Reload ( development mode ) 14 | 15 | ```bash 16 | yarn serve 17 | ``` 18 | 19 | ### Compiles and Minifies ( production mode ) 20 | 21 | ```bash 22 | yarn run build 23 | ``` 24 | 25 | ### Customize Configuration 26 | 27 | [Configuration Reference](https://cli.vuejs.org/zh/). 28 | 29 | --- 30 | 31 | ### Mock Server 32 | 33 | [Mock Repo](https://github.com/joenix/mock-server) 34 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-staff", 3 | "version": "1.0.1", 4 | "private": false, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "@cafee/staff": "^1.1.35", 12 | "ant-design-vue": "^1.3.8", 13 | "element-ui": "^2.8.2" 14 | }, 15 | "devDependencies": { 16 | "@vue/cli-plugin-babel": "^3.6.0", 17 | "@vue/cli-plugin-eslint": "^3.6.0", 18 | "@vue/cli-service": "^3.6.0", 19 | "babel-eslint": "^10.0.1", 20 | "eslint": "^5.16.0", 21 | "eslint-plugin-vue": "^5.0.0", 22 | "less": "^3.9.0", 23 | "less-loader": "^4.1.0", 24 | "node-sass": "^4.12.0", 25 | "sass-loader": "^7.1.0", 26 | "style-resources-loader": "^1.2.1", 27 | "vue-cli-plugin-style-resources-loader": "^0.1.3", 28 | "vue-template-compiler": "^2.5.21" 29 | }, 30 | "eslintConfig": { 31 | "root": true, 32 | "env": { 33 | "node": true 34 | }, 35 | "extends": [ 36 | "plugin:vue/essential", 37 | "eslint:recommended" 38 | ], 39 | "rules": {}, 40 | "parserOptions": { 41 | "parser": "babel-eslint" 42 | } 43 | }, 44 | "postcss": { 45 | "plugins": { 46 | "autoprefixer": {} 47 | } 48 | }, 49 | "browserslist": [ 50 | "> 1%", 51 | "last 2 versions", 52 | "not ie <= 8" 53 | ], 54 | "license": "MIT" 55 | } 56 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joenix/vue-staff/85801b0e61b2962d21683abb7b5b8aabe1a115ea/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | vue-staff 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 24 | 25 | 35 | 36 | 41 | 42 | 47 | 48 | 53 | -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joenix/vue-staff/85801b0e61b2962d21683abb7b5b8aabe1a115ea/src/assets/logo.png -------------------------------------------------------------------------------- /src/components/hello/index.js: -------------------------------------------------------------------------------- 1 | export { default } from './src/index.vue' 2 | -------------------------------------------------------------------------------- /src/components/hello/src/index.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /src/components/mixin.js: -------------------------------------------------------------------------------- 1 | export default { 2 | methods: { 3 | plus(info) { 4 | return (info += info); 5 | } 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /src/components/sample/index.js: -------------------------------------------------------------------------------- 1 | export { default } from './src/index.vue' 2 | -------------------------------------------------------------------------------- /src/components/sample/src/index.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 119 | -------------------------------------------------------------------------------- /src/components/sample/style.less: -------------------------------------------------------------------------------- 1 | .sample { 2 | } 3 | -------------------------------------------------------------------------------- /src/i18n/zh-CN.js: -------------------------------------------------------------------------------- 1 | export default { 2 | slogan: "欢迎使用 Vue Staff 脚手架" 3 | }; 4 | -------------------------------------------------------------------------------- /src/i18n/zh-TW.js: -------------------------------------------------------------------------------- 1 | export default { 2 | slogan: "歡迎使用 Vue Staff 腳手架" 3 | }; 4 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | // Create Project using Staff 2 | import Staff from "@cafee/staff"; 3 | 4 | // Import Registry 5 | import { router, modules, components, i18n } from "./registry"; 6 | 7 | // Import Utils 8 | import { log, exceptor, language, interceptor } from "./utils"; 9 | 10 | // Use Ant 11 | import Ant from "ant-design-vue"; 12 | 13 | // Import App 14 | import App from "./App.vue"; 15 | 16 | // Initialization 17 | new Staff({ 18 | /* Manifest */ 19 | }) 20 | 21 | // Initialize Vue 22 | .then( 23 | // Start 24 | ({ Vue, Router, Vuex, Importz, Axios, I18n, Console, Global }, next) => { 25 | /** 26 | * Extention Code Here 27 | * ======== ======== ======== 28 | */ 29 | Vue.config.productionTip = false; 30 | 31 | /** 32 | * Vue Useable 33 | * ======== ======== ======== 34 | */ 35 | 36 | // Ant Design 37 | Vue.use(Ant); 38 | 39 | /** 40 | * Kit Transform 41 | * ======== ======== ======== 42 | */ 43 | 44 | // Console 45 | Global.Console = new log(); 46 | 47 | // Exceptor 48 | exceptor(Global); 49 | 50 | // Language 51 | Vue.prototype.$lang = language; 52 | 53 | // HTTP Interceptor 54 | Vue.prototype.$http = interceptor( 55 | // Axe 56 | Axios, 57 | 58 | // Configure 59 | { 60 | // Proposal /api/ 61 | baseURL: "", 62 | // Out Time 63 | timeout: 8000 64 | }, 65 | 66 | // Request Transform 67 | (data, header) => { 68 | console.log("Request ===>", data, "Header ===>", header); 69 | }, 70 | 71 | // Response Transform 72 | response => { 73 | console.log("Response ===>", response); 74 | }, 75 | 76 | // Error Transform 77 | error => (Global.Console.error(error), error) 78 | ); 79 | 80 | /** 81 | * Part Registry 82 | * ======== ======== ======== 83 | */ 84 | 85 | // Components 86 | Importz(components, name => 87 | // Register 88 | Vue.component(`x-${name}`, () => import(`@component/${name}`)) 89 | ); 90 | 91 | // Modules 92 | const $module = Importz( 93 | modules, 94 | ( 95 | name, 96 | cip, 97 | // Get Module Set 98 | mod = require(`@module/${name}`).default(Vue.prototype.$http) 99 | ) => ( 100 | // Use Namespaced 101 | (mod.namespaced = true), 102 | // Return 103 | cip(mod) 104 | ) 105 | ); 106 | 107 | // I18n 108 | const $i18n = new I18n({ 109 | // Language 110 | locale: language, 111 | // Infomation 112 | messages: Importz(i18n, (name, cip) => 113 | // Collection 114 | cip(require(`@i18n/${name}`)) 115 | ) 116 | }); 117 | 118 | // Router 119 | const $router = new Router({ 120 | // Router Mode 121 | mode: "history", 122 | // Base Uri 123 | base: process.env.BASE_URL, 124 | // Routes 125 | routes: [ 126 | /* Rtouer Configure */ 127 | ...router 128 | ] 129 | }); 130 | 131 | // Store 132 | const $store = new Vuex.Store({ 133 | // Name Space 134 | namespaced: true, 135 | // Use Modules 136 | modules: { ...$module } 137 | }); 138 | 139 | /** 140 | * Vue Instance 141 | * ======== ======== ======== 142 | */ 143 | const $vue = new Vue({ 144 | // Router 145 | router: $router, 146 | // Store 147 | store: $store, 148 | // i18n 149 | i18n: $i18n, 150 | // Render 151 | render: h => h(App) 152 | }); 153 | 154 | // Mount 155 | $vue.$mount("#app"); 156 | 157 | /** 158 | * Transfer 159 | * ======== ======== ======== 160 | */ 161 | return $vue; 162 | } 163 | ) 164 | 165 | // End 166 | .finally(v => Console.info("vue-staff is running .")); 167 | -------------------------------------------------------------------------------- /src/modules/about.js: -------------------------------------------------------------------------------- 1 | export default $http => { 2 | return { state: "About State" }; 3 | }; 4 | -------------------------------------------------------------------------------- /src/modules/home.js: -------------------------------------------------------------------------------- 1 | export default $http => { 2 | return { 3 | state: { 4 | message: "About State", 5 | mock: "No Mock" 6 | }, 7 | actions: { 8 | getMock(ctx) { 9 | $http 10 | .auto("/mock/home!post", { a: 1 }) 11 | .then(response => (ctx.state.mock = response.data)); 12 | } 13 | } 14 | }; 15 | }; 16 | -------------------------------------------------------------------------------- /src/registry/components.js: -------------------------------------------------------------------------------- 1 | export default ["sample", "hello"]; 2 | -------------------------------------------------------------------------------- /src/registry/i18n.js: -------------------------------------------------------------------------------- 1 | export default ["zh-CN", "zh-TW"]; 2 | -------------------------------------------------------------------------------- /src/registry/index.js: -------------------------------------------------------------------------------- 1 | import router from "./router"; 2 | import store from "./store"; 3 | import modules from "./modules"; 4 | import components from "./components"; 5 | import i18n from "./i18n"; 6 | 7 | export { router, store, modules, components, i18n }; 8 | -------------------------------------------------------------------------------- /src/registry/modules.js: -------------------------------------------------------------------------------- 1 | export default ["home", "about"]; 2 | -------------------------------------------------------------------------------- /src/registry/router.js: -------------------------------------------------------------------------------- 1 | export default [ 2 | { 3 | path: "/", 4 | name: "home", 5 | component: () => import("../views/Home.vue") 6 | }, 7 | { 8 | path: "/about", 9 | name: "about", 10 | component: () => import("../views/About.vue") 11 | } 12 | ]; 13 | -------------------------------------------------------------------------------- /src/registry/store.js: -------------------------------------------------------------------------------- 1 | export default { 2 | state: {}, 3 | mutations: {}, 4 | actions: {} 5 | }; 6 | -------------------------------------------------------------------------------- /src/sheet/skin/ant-design.less: -------------------------------------------------------------------------------- 1 | @color__background: MistyRose; 2 | -------------------------------------------------------------------------------- /src/sheet/skin/element-ui.scss: -------------------------------------------------------------------------------- 1 | $color__border: LightCoral; 2 | -------------------------------------------------------------------------------- /src/sheet/variable/colour.less: -------------------------------------------------------------------------------- 1 | --color__primary: #4A87FA; 2 | --color__error: #FE5B57; 3 | --color__warning: #FAAD14; 4 | --color__success: #23D6BB; 5 | -------------------------------------------------------------------------------- /src/sheet/variable/family.less: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joenix/vue-staff/85801b0e61b2962d21683abb7b5b8aabe1a115ea/src/sheet/variable/family.less -------------------------------------------------------------------------------- /src/sheet/variable/index.less: -------------------------------------------------------------------------------- 1 | :root 2 | { 3 | /* 预置 */ 4 | @import 'preset'; 5 | /* 配色 */ 6 | @import 'colour'; 7 | /* 字体 */ 8 | @import 'family'; 9 | /* 字号 */ 10 | @import 'size'; 11 | /* 空间 */ 12 | @import 'space'; 13 | /* 速度 */ 14 | @import 'speed'; 15 | } 16 | -------------------------------------------------------------------------------- /src/sheet/variable/preset.less: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joenix/vue-staff/85801b0e61b2962d21683abb7b5b8aabe1a115ea/src/sheet/variable/preset.less -------------------------------------------------------------------------------- /src/sheet/variable/size.less: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joenix/vue-staff/85801b0e61b2962d21683abb7b5b8aabe1a115ea/src/sheet/variable/size.less -------------------------------------------------------------------------------- /src/sheet/variable/space.less: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joenix/vue-staff/85801b0e61b2962d21683abb7b5b8aabe1a115ea/src/sheet/variable/space.less -------------------------------------------------------------------------------- /src/sheet/variable/speed.less: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joenix/vue-staff/85801b0e61b2962d21683abb7b5b8aabe1a115ea/src/sheet/variable/speed.less -------------------------------------------------------------------------------- /src/utils/exceptor.js: -------------------------------------------------------------------------------- 1 | export default Global => { 2 | Global.onerror = (message, url, line, column, error) => ( 3 | Global.Console.error( 4 | `${message}\n ${url}`, 5 | `line:${line} column:${column}` 6 | ), 7 | true 8 | ); 9 | }; 10 | -------------------------------------------------------------------------------- /src/utils/index.js: -------------------------------------------------------------------------------- 1 | import log from "./log"; 2 | import exceptor from "./exceptor"; 3 | import language from "./language"; 4 | import interceptor from "./interceptor"; 5 | 6 | export { log, exceptor, language, interceptor }; 7 | -------------------------------------------------------------------------------- /src/utils/interceptor.js: -------------------------------------------------------------------------------- 1 | export default ( 2 | Axios, 3 | configure, 4 | requestTransform = () => {}, 5 | responseTransform = () => {}, 6 | errorTransform = () => {} 7 | ) => { 8 | // Instance 9 | const http = Axios.create(configure); 10 | 11 | // Interceptor Request 12 | http.interceptors.request.use( 13 | // Handler 14 | config => { 15 | // Credential Token 16 | config.withCredentials = true; 17 | 18 | // Content Type 19 | config.headers["Content-Type"] = "application/x-www-form-urlencoded"; 20 | 21 | // Transform 22 | requestTransform( 23 | config.method === "get" ? config.params : config.data, 24 | config.headers 25 | ); 26 | 27 | // Result 28 | return config; 29 | }, 30 | 31 | // Error 32 | error => Promise.reject(errorTransform(error)) 33 | ); 34 | 35 | // Interceptor Response 36 | http.interceptors.response.use( 37 | // Handler 38 | response => { 39 | // Transform 40 | responseTransform(response.data); 41 | // Result 42 | return response; 43 | }, 44 | 45 | // Error 46 | error => Promise.reject(errorTransform(error)) 47 | ); 48 | 49 | // API 50 | const API = { 51 | // Get 52 | get: (uri, params) => http.get(uri, { params }), 53 | // Post 54 | post: (uri, params) => http.post(uri, params), 55 | // Put 56 | put: (uri, params) => http.put(uri, params), 57 | // Delete 58 | delete: (uri, params) => http.delete(uri, params) 59 | }; 60 | 61 | // Export API 62 | return { 63 | // Auto Http 64 | auto(uri, params, method = "get", exp = new RegExp(/\![a-zA-Z]{3,6}$/g)) { 65 | // Check Method with End 66 | uri = uri.replace(exp, w => 67 | (m => { 68 | if (m in API) return (method = m), ""; 69 | })(w.substr(1)) 70 | ); 71 | // Use Method in API 72 | return API[method](uri, params); 73 | }, 74 | // Merge 75 | ...API 76 | }; 77 | }; 78 | -------------------------------------------------------------------------------- /src/utils/language.js: -------------------------------------------------------------------------------- 1 | export default navigator.language || navigator.userLanguage; 2 | -------------------------------------------------------------------------------- /src/utils/log.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Permission Map 3 | */ 4 | const permission = new Map([[0, "DEBUG"], [1, "ERROR"], [2, "DISABLE"]]); 5 | 6 | /* !! 7 | * Logger Record 8 | * -------- -------- -------- 9 | * Use Development Only 10 | * ======== ======== ======== 11 | */ 12 | class Logger { 13 | /** 14 | * Permission Level: [0, 1, 2] 15 | */ 16 | level; 17 | 18 | /** 19 | * In Production: Boolean 20 | */ 21 | inProduction; 22 | 23 | /** 24 | * Show Production: Boolean 25 | */ 26 | showProduction; 27 | 28 | // Logger Recoder 29 | constructor( 30 | // Default Permission Level is 0 31 | level = permission.get(0), 32 | // Default Not Show in Production 33 | showProduction = false 34 | ) { 35 | // Noop 36 | this.noop = function() {}; 37 | 38 | // In node.js 39 | this.inServer = typeof window === "undefined"; 40 | 41 | // In Production 42 | this.inProduction = process.env.NODE_ENV === "production"; 43 | 44 | // Show Production 45 | this.showProduction = showProduction; 46 | 47 | // Set Permission Level 48 | this.level = level; 49 | 50 | // Style 51 | this.style = color => 52 | `color: white; background: ${color}; border-radius: 2px; text-shadow: 0 -1px 1px rgba(0, 0, 0, .25); padding: 4px; font-weight: bold; font-size: 12px'`; 53 | } 54 | 55 | // Can Print in Environment 56 | can(method, allow = []) { 57 | // Full Mode 58 | if (this.level === permission.get(0) && this.inProduction === false) { 59 | allow = ["INFO", "WARN", "ERROR", "DEBUG"]; 60 | } 61 | 62 | // Error Mode 63 | else if ( 64 | this.level === permission.get(1) && 65 | (this.inProduction === false || this.showProduction === true) 66 | ) { 67 | allow = ["ERROR"]; 68 | } 69 | 70 | // Disable Mode 71 | else if ( 72 | this.level === permission.get(2) || 73 | (this.inProduction === true && this.showProduction === false) 74 | ) { 75 | allow = []; 76 | } 77 | 78 | // Check Method 79 | return !!~allow.indexOf(method); 80 | } 81 | 82 | /** 83 | * Print 84 | * -------- -------- -------- 85 | * @param mode 86 | * @param color 87 | * @param message 88 | * @param tag 89 | * @param context 90 | * ======== ======== ======== 91 | */ 92 | print(mode, color, message, tag, context = "") { 93 | // Bind Console 94 | return (tag 95 | ? // Has Tag 96 | console[mode].bind( 97 | // Console 98 | window.console, 99 | 100 | // Prefix Info 101 | `%c${mode.toUpperCase()}%c %c` + tag + "%c " + message, 102 | // Prefix Color 103 | this.style(color), 104 | 105 | // Print Color 106 | "color: inherit", 107 | // Print Style 108 | this.style("gray"), 109 | 110 | // Context Weight 111 | "font-weight: bold", 112 | 113 | // Context Info 114 | context 115 | ) 116 | : // No Tag 117 | console[mode].bind( 118 | // Console 119 | window.console, 120 | 121 | // Prefix Info 122 | `%c${mode.toUpperCase()}%c ${message}`, 123 | // Prefix Color 124 | this.style(color), 125 | 126 | // Context Weight 127 | "font-weight: bold", 128 | 129 | // Context Info 130 | context 131 | ))(); 132 | } 133 | 134 | /** 135 | * Debug Level 136 | * -------- -------- -------- 137 | * @param message 138 | * @param tag 139 | * @param context 140 | * ======== ======== ======== 141 | */ 142 | debug(message, tag, context) { 143 | if (!this.inServer && this.can("DEBUG")) { 144 | return this.print("debug", "grey", message, tag, context); 145 | } 146 | 147 | // Non Conformity 148 | return this.noop; 149 | } 150 | 151 | /** 152 | * Log Level 153 | * -------- -------- -------- 154 | * @param message 155 | * @param tag 156 | * @param context 157 | * ======== ======== ======== 158 | */ 159 | log(message, tag, context) { 160 | // return this.info(message, tag, context); 161 | if (!this.inServer) { 162 | return this.print("log", "dimgray", message, tag, context); 163 | } 164 | 165 | // Non Conformity 166 | return this.noop; 167 | } 168 | 169 | /** 170 | * Success Level 171 | * -------- -------- -------- 172 | * @param message 173 | * @param tag 174 | * @param context 175 | * ======== ======== ======== 176 | */ 177 | info(message, tag, context) { 178 | if (!this.inServer && this.can("DEBUG")) { 179 | return this.print("info", "green", message, tag, context); 180 | } 181 | 182 | // Non Conformity 183 | return this.noop; 184 | } 185 | 186 | /** 187 | * Warnning Level 188 | * -------- -------- -------- 189 | * @param message 190 | * @param tag 191 | * @param context 192 | * ======== ======== ======== 193 | */ 194 | warn(message, tag, context) { 195 | if (!this.inServer && this.can("WARN")) { 196 | return this.print("warn", "orange", message, tag, context); 197 | } 198 | 199 | // Non Conformity 200 | return this.noop; 201 | } 202 | 203 | /** 204 | * Error Level 205 | * -------- -------- -------- 206 | * @param message 207 | * @param tag 208 | * @param context 209 | * ======== ======== ======== 210 | */ 211 | error(message, tag, context) { 212 | if (!this.inServer && this.can("ERROR")) { 213 | return this.print("error", "red", message, tag, context); 214 | } 215 | 216 | // Non Conformity 217 | return this.noop; 218 | } 219 | } 220 | 221 | // Export 222 | export default Logger; 223 | -------------------------------------------------------------------------------- /src/views/About.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 17 | -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | const Path = require("path"); 2 | 3 | function resolve(dir) { 4 | return Path.resolve(__dirname, dir); 5 | } 6 | 7 | function env(vars) { 8 | return process.env[vars]; 9 | } 10 | 11 | module.exports = { 12 | productionSourceMap: false, 13 | 14 | devServer: { 15 | host: "0.0.0.0", 16 | proxy: { 17 | "/api": { 18 | target: process.env.proxy, 19 | pathRewrite: { 20 | "^/api": "/" 21 | }, 22 | changeOrigin: true 23 | }, 24 | "/mock": { 25 | target: "http://localhost:3000/", 26 | pathRewrite: { 27 | "^/mock": "/" 28 | }, 29 | changeOrigin: true 30 | } 31 | } 32 | }, 33 | 34 | pluginOptions: { 35 | "style-resources-loader": { 36 | preProcessor: "less", 37 | patterns: [ 38 | resolve("./src/sheet/skin/ant-design.less"), 39 | resolve("./src/sheet/variable/index.less") 40 | ] 41 | } 42 | }, 43 | 44 | css: { 45 | extract: true, 46 | modules: true, 47 | loaderOptions: { 48 | less: { 49 | javascriptEnabled: true 50 | }, 51 | sass: { 52 | data: `@import "~@sheet/skin/element-ui.scss";` 53 | } 54 | } 55 | }, 56 | 57 | chainWebpack: config => { 58 | // Use Polyfill 59 | config.entry.app = ["babel-polyfill", resolve("src/main.js")]; 60 | // Alias Name 61 | config.resolve.alias 62 | // node_modules 63 | .set("#", resolve("node_modules")) 64 | // src 65 | .set("@", resolve("src")) 66 | // module 67 | .set("@module", resolve("src/modules")) 68 | // i18n 69 | .set("@i18n", resolve("src/i18n")) 70 | // component 71 | .set("@component", resolve("src/components")) 72 | // view 73 | .set("@view", resolve("src/views")) 74 | // sheet 75 | .set("@sheet", resolve("src/sheet")) 76 | // asset 77 | .set("@asset", resolve("src/assets")); 78 | }, 79 | 80 | configureWebpack: config => { 81 | // Read GQL File 82 | config.module.rules.push({ 83 | test: /\.(graphql|gql)$/, 84 | exclude: /node_modules/, 85 | loader: "graphql-tag/loader" 86 | }); 87 | } 88 | }; 89 | --------------------------------------------------------------------------------