refactor: 前端分开构建

This commit is contained in:
Captain.B 2021-07-02 14:01:53 +08:00 committed by 刘瑞斌
parent 8635886cde
commit c7cb74be3a
3 changed files with 58 additions and 23 deletions

View File

@ -55,12 +55,30 @@
</execution> </execution>
<!-- Build and minify static files --> <!-- Build and minify static files -->
<execution> <execution>
<id>yarn build</id> <id>yarn build business</id>
<goals> <goals>
<goal>yarn</goal> <goal>yarn</goal>
</goals> </goals>
<configuration> <configuration>
<arguments>build</arguments> <arguments>build business</arguments>
</configuration>
</execution>
<execution>
<id>yarn build login</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>build login</arguments>
</configuration>
</execution>
<execution>
<id>yarn build document</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>build document</arguments>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>

View File

@ -1,5 +1,5 @@
import Vue from 'vue'; import Vue from 'vue';
import {Button, Col, Form, FormItem, Input, Row, RadioGroup} from 'element-ui'; import {Button, Col, Form, FormItem, Input, Row, RadioGroup, Radio} from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'; import 'element-ui/lib/theme-chalk/index.css';
import Login from "./Login.vue"; import Login from "./Login.vue";
import Ajax from "../common/js/ajax"; import Ajax from "../common/js/ajax";
@ -18,6 +18,7 @@ Vue.use(FormItem);
Vue.use(Input); Vue.use(Input);
Vue.use(Button); Vue.use(Button);
Vue.use(RadioGroup); Vue.use(RadioGroup);
Vue.use(Radio);
Vue.use(Ajax); Vue.use(Ajax);

View File

@ -1,23 +1,12 @@
const path = require('path') const path = require('path');
function resolve(dir) { function resolve(dir) {
return path.join(__dirname, dir) return path.join(__dirname, dir);
} }
module.exports = { let projectName = process.argv[3];
productionSourceMap: false,
devServer: { const projects = {
port: 8080,
proxy: {
//1.8需求:增加分享功能,不登陆即可看到文档页面。所以代理设置增加了(?!/document)文档页面的相关信息
// ['^(?!/login)']: {
['^((?!/login)(?!/document))']: {
target: 'http://localhost:8081',
ws: true,
},
}
},
pages: {
business: { business: {
entry: "src/business/main.js", entry: "src/business/main.js",
template: "src/business/index.html", template: "src/business/index.html",
@ -33,7 +22,34 @@ module.exports = {
template: "src/document/document.html", template: "src/document/document.html",
filename: "document.html" filename: "document.html"
} }
};
const getPage = function (projectName) {
if (!projectName) {
return projects;
}
return {
[projectName]: projects[projectName]
};
};
let pages = getPage(projectName);
module.exports = {
productionSourceMap: false,
devServer: {
port: 8080,
proxy: {
//1.8需求:增加分享功能,不登陆即可看到文档页面。所以代理设置增加了(?!/document)文档页面的相关信息
// ['^(?!/login)']: {
['^((?!/login)(?!/document))']: {
target: 'http://localhost:8081',
ws: true,
}, },
}
},
pages: pages,
configureWebpack: { configureWebpack: {
devtool: 'source-map', devtool: 'source-map',
resolve: { resolve: {
@ -43,6 +59,6 @@ module.exports = {
} }
}, },
chainWebpack(config) { chainWebpack(config) {
config.plugins.delete('prefetch') config.plugins.delete('prefetch');
} }
}; };