Skip to content

Commit 41a7e02

Browse files
committed
feat: ✨ 提供多页面构建示例,优化了打包分包,取消CDN加载依赖但保留了设置入口
1 parent a947e40 commit 41a7e02

File tree

15 files changed

+409
-96
lines changed

15 files changed

+409
-96
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ The following access addresses are built and deployed by the latest master branc
9797
* Multiple tabs support drag and drop sorting `1.8.0 +`
9898
* load only local JavaScript code less than 60kb on the homepage `1.8.0 +`
9999
* Built in build file volume checking tool `1.8.0 +`
100+
* Example of multi page `1.23.0 +`
101+
* Split chunks `1.23.0 +`
100102

101103
## Other synchronous repositories
102104

README.zh.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
* 多标签页支持拖拽排序 `1.8.0 +`
9898
* 优化生产环境构建,首页只加载小于 60kb 的本地 js 代码 `1.8.0 +`
9999
* 内置了构建文件体积检查工具 `1.8.0 +`
100+
* 构建多页面示例 `1.23.0 +`
101+
* 分包优化 `1.23.0 +`
100102

101103
## 其它同步仓库
102104

babel.config.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ module.exports = {
22
presets: [
33
'@vue/cli-plugin-babel/preset'
44
],
5-
// 允许两种编码引入方式共存,也就是 common 规范与 es6 规范的共存处理
5+
plugins: [
6+
[
7+
'import',
8+
{
9+
libraryName: 'vant',
10+
libraryDirectory: 'es',
11+
style: (name) => `${name}/style/less`
12+
},
13+
'vant'
14+
]
15+
],
16+
// common + es6 共存
617
sourceType: 'unambiguous'
718
}

dependencies-cdn.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

package-lock.json

Lines changed: 137 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"simplemde": "^1.11.2",
3939
"sortablejs": "^1.10.1",
4040
"ua-parser-js": "^0.7.20",
41+
"vant": "^2.11.1",
4142
"vue": "^2.6.11",
4243
"vue-grid-layout": "^2.3.7",
4344
"vue-i18n": "^8.15.1",
@@ -59,6 +60,7 @@
5960
"@vue/eslint-config-standard": "^5.1.2",
6061
"@vue/test-utils": "^1.0.2",
6162
"babel-eslint": "^10.0.3",
63+
"babel-plugin-import": "^1.13.3",
6264
"compression-webpack-plugin": "^3.0.1",
6365
"cz-conventional-changelog": "^3.2.0",
6466
"eslint": "^6.8.0",
@@ -67,6 +69,8 @@
6769
"eslint-plugin-promise": "^4.2.1",
6870
"eslint-plugin-standard": "^4.0.1",
6971
"eslint-plugin-vue": "^6.2.2",
72+
"less": "^3.12.2",
73+
"less-loader": "^7.1.0",
7074
"sass": "^1.23.7",
7175
"sass-loader": "^8.0.0",
7276
"svg-sprite-loader": "^4.1.6",

public/index.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@
77
<link rel="icon" href="<%= BASE_URL %>icon.ico">
88
<!-- 使用 CDN 加速的 CSS 文件,配置在 vue.config.js 下 -->
99
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %>
10-
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="preload" as="style">
1110
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet">
1211
<% } %>
13-
<!-- 使用 CDN 加速的 JS 文件,配置在 vue.config.js 下 -->
14-
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %>
15-
<link href="<%= htmlWebpackPlugin.options.cdn.js[i] %>" rel="preload" as="script">
16-
<% } %>
1712
<title><%= VUE_APP_TITLE %></title>
1813
<style>
1914
html, body, #app { height: 100%; margin: 0px; padding: 0px; width: 100%; }
@@ -23,6 +18,7 @@
2318
.d2-home__footer > a { font-size: 12px; color: #ABABAB; text-decoration: none; }
2419
.d2-home__loading { height: 32px; width: 32px; margin-bottom: 20px; }
2520
</style>
21+
<!-- 统计代码 帮助 D2Admin 作者大致统计使用此框架的用户数量 -->
2622
<script>
2723
var _hmt = _hmt || [];
2824
var hmid = "bc38887aa5588add05a38704342ad7e8";

public/mobile.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" >
6+
<link rel="icon" href="<%= BASE_URL %>icon.ico">
7+
<!-- 使用 CDN 加速的 CSS 文件,配置在 vue.config.js 下 -->
8+
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %>
9+
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet">
10+
<% } %>
11+
<title><%= VUE_APP_TITLE %></title>
12+
<!-- 统计代码 帮助 D2Admin 作者大致统计使用此框架的用户数量 -->
13+
<script>
14+
var _hmt = _hmt || [];
15+
var hmid = "bc38887aa5588add05a38704342ad7e8";
16+
(function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?" + hmid; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s);})();
17+
</script>
18+
</head>
19+
<body>
20+
<div id="app"></div>
21+
<!-- 使用 CDN 加速的 JS 文件,配置在 vue.config.js 下 -->
22+
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %>
23+
<script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
24+
<% } %>
25+
</body>
26+
</html>

src.mobile/App.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div id="app">
3+
<router-view/>
4+
</div>
5+
</template>

src.mobile/main.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Vue from 'vue'
2+
import App from './App.vue'
3+
import router from './router'
4+
import store from './store'
5+
6+
import 'flex.css'
7+
import './vant'
8+
9+
Vue.config.productionTip = false
10+
11+
new Vue({
12+
router,
13+
store,
14+
render: h => h(App)
15+
}).$mount('#app')

0 commit comments

Comments
 (0)