Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 048d008

Browse files
路由 history 模式下,多模块配置
1 parent e2a1a6a commit 048d008

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

‎build/dev.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ var compiler = webpack(devConfig);
66
var server = new webpackDevServer(compiler, {
77
hot: true,
88
quiet: true,
9+
historyApiFallback: {
10+
rewrites: [
11+
{ from: /^\/web/, to: '/web/index.html' },
12+
{ from: /^\/admin/, to: '/admin/index.html' }
13+
]
14+
},
915
publicPath: config.dev.outputPublicPath,
1016
stats: { colors: true }
1117
});

‎build/utils.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ exports.genHtmlPlugins = function () {
7070
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
7171
plugins.push(
7272
new HtmlWebpackPlugin({
73-
filename: isProd ? path.resolve(__dirname, `../dist/${name}/index.html`) : name+'.html',
73+
filename: isProd ? path.resolve(__dirname, `../dist/${name}/index.html`) : `${name}/index.html`,
7474
template: 'index.tpl.html',
7575
chunks: isProd ? ['manifest','vendor',`${name}-vendor`, name] : [name],
7676
inject: true

‎src/admin/router.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import index from './views/index.vue'
22
import table from './views/table.vue'
33
export default {
4+
base: process.env.NODE_ENV === "production" ? '/' : '/admin/',
5+
mode: 'history',
46
linkActiveClass: 'active',
57
routes: [{
68
path: '/',
79
component: index
8-
},{
10+
},{
911
path: '/table',
1012
component: table
1113
}]

‎src/web/router.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import sass from './views/sass.vue'
66
import image from './views/image.vue'
77
import iconfont from './views/iconfont.vue'
88
export default {
9+
base: process.env.NODE_ENV === "production" ? '/' : '/web/',
10+
mode: 'history',
911
linkActiveClass: 'active',
1012
routes: [{
1113
path: '/',

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /