-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
127 lines (113 loc) · 4.06 KB
/
vue.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// const apiMocker = require("webpack-api-mocker");
const path = require("path");
// const mocker = path.resolve(__dirname, "./mock/data.js");
// vue.config.js 配置说明 (这个file是peter我加的)
// 这里只列一部分,具体配置惨考文档啊
process.env.VUE_APP_VERSION = require("./package.json").version;
const prodEnv = "production";
let isRelease = false;
if (process.env.NODE_ENV === prodEnv) {
let argvs = process.argv;
if (argvs && argvs.length > 0) {
let paramIndex = argvs.indexOf("--target");
let paramValIndex = argvs.indexOf("lib");
console.log(paramIndex, paramValIndex);
if (paramIndex + 1 == paramValIndex) {
isRelease = true;
}
}
}
module.exports = {
// baseUrl type:{string} default:'/'
// 将部署应用程序的基本URL
// 将部署应用程序的基本URL
// 默认情况下,Vue CLI假设您的应用程序将部署在域的根目录下。
// https://www.my-app.com/。如果应用程序部署在子路径上,则需要使用此选项指定子路径。例如,如果您的应用程序部署在https://www.foobar.com/my-app/,集baseUrl到'/my-app/'.
// baseUrl: process.env.NODE_ENV === 'production' ? '/online/' : '/test/',
// baseUrl: "",
publicPath: "",
// outputDir: 在npm run build时 生成文件的目录 type:string, default:'dist'
// outputDir: 'dist',
outputDir: isRelease ? "dist" : "../vue3-easy-form-docs/demo",
// pages:{ type:Object,Default:undfind }
/*
构建多页面模式的应用程序.每个“页面”都应该有一个相应的JavaScript条目文件。该值应该是一
个对象,其中键是条目的名称,而该值要么是指定其条目、模板和文件名的对象,要么是指定其条目
的字符串,
注意:请保证pages里配置的路径和文件名 在你的文档目录都存在 否则启动服务会报错的
*/
configureWebpack: config => {
if (isRelease) {
if (!config.output) {
config.output = {};
}
config.output.library = "esForm";
config.output.libraryExport = "default";
config.externals = {
...config.externals,
vue: {
root: "Vue",
commonjs2: "vue",
commonjs: "vue",
amd: "vue"
},
"element-ui": {
root: "ELEMENT",
commonjs2: "ELEMENT",
commonjs: "ELEMENT",
amd: "ELEMENT"
},
axios: {
root: "axios",
commonjs2: "axios",
commonjs: "axios",
amd: "axios"
}
};
}
var otherAlias = {};
otherAlias["vue3-easy-form"] = path.resolve(
__dirname,
"./src/package/index.js"
);
if (!config.resolve.alias) {
config.resolve.alias = {};
}
Object.assign(config.resolve.alias, otherAlias);
},
css: {
extract: false // 是否内联css
},
// lintOnSave:{ type:Boolean default:true } 问你是否使用eslint
lintOnSave: process.env.NODE_ENV !== prodEnv ? true : false, // eslint-loader 是否在保存的时候检查
// productionSourceMap:{ type:Bollean,default:true } 生产源映射
// 如果您不需要生产时的源映射,那么将此设置为false可以加速生产构建
productionSourceMap: false,
// devServer:{type:Object} 3个属性host,port,https
// 它支持webPack-dev-server的所有选项
devServer: {
port: 8086, // 端口号
// // host: 'localhost', //不要写这个东西,要写就写127.0.0.1
// // https: false, // https:{type:Boolean}
open: true //配置自动启动浏览器
// before: (app) => {
// apiMocker(app, mocker, {
// proxy: {
// // '/api/*': 'http://domain.com.com' //当没有mock数据,只符合此规则,则转换
// },
// changeHost: true
// });
// },
// proxy: 'http://localhost:4000' // 配置跨域处理,只有一个代理
// proxy: {
// '/api': {
// target: '/mock/data.js',
// ws: true,
// changeOrigin: true
// },
// '/foo': {
// target: '<other_url>'
// }
// }, // 配置多个代理
}
};