vue--配置多入口程序

1 module.exports = {
2     entry: {
3         app:'.src/main.js',
4         admin:'./src/admin-main.js'  
5     }          
6 }

在多数情况下,程序入口只有一个,就是main.js。但是如果用户使用的是.../index这个网址,而后台提供给登录用户的是.../admin

就需要多入口了

1.在build/webpack.base.conf.js配置文件中的entry配置属性上加上新的入口文件,如上代码

2.在build/webpack.dev.config.js文件的plugins配置项内多配置一个HTMLWebpackPlugin插件,用于生成admin.html入口页

具体请看

 1 plugins: [
 2     new HTMLWebpackPlugin({
 3         filename:process.env.NODE_ENV === 'testing'
 4         ? 'index.html'
 5         :config.build.index,
 6         template: 'index.html',
 7         chunks:['app'],
 8         inject:true,
 9         minify: {
10             removeComments:true,
11             collapseWhitespace:true,
12             removeAttributeQuotes: true
13         },
14         chunksSortMode: 'dependency'
15     })
16 //这是新增项,用于匹配注入admin.js的输出脚本
17     new HTMLWebpackPlugin({
18             filename:process.env.NODE_ENV === 'testing'
19             ? 'admin.html'
20             :config.build.admin,
21             template: 'index.html',
22             chunks:['admin'],
23             inject:true,
24             minify: {
25                 removeComments:true,
26                 collapseWhitespace:true,
27                 removeAttributeQuotes: true
28             },
29             chunksSortMode: 'dependency'
30     })
31     
32 ]
View Code

猜你喜欢

转载自www.cnblogs.com/lizitangtang/p/9548812.html
今日推荐