在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue多頁面的打包路徑有誤怎么解決?

vue多頁面的打包路徑有誤怎么解決?

現(xiàn)在的問題是,后端需要做一個叫做 '路徑攔截'的東西,于是我打包的文件夾層級關(guān)系如圖所示。圖片描述

既然是這樣,我的build或者config該如何配置才能讓login.html和index.html正常的引用Js,css等資源。并且Login.html有個登錄后需要跳轉(zhuǎn)到index.html。這個跳轉(zhuǎn)路徑又該如何寫?
希望大佬不吝賜教。

回答
編輯回答
傲寒

webpack的多入口文件配置,會自動生成多個入口文件,至于html這個不重要,你自己創(chuàng)建就可以了,只要引用的js正確就可以

2017年9月25日 03:12
編輯回答
毀與悔

建議是做成類似 2 樓的動態(tài)讀取的方式,不要手工配置多入口

2018年6月25日 08:23
編輯回答
厭遇

手上有個項目是一樣的,屬于多入口項目,有3個html文件,對應(yīng)有3個js入口文件
clipboard.png

config.js部分,HTMLDirs里面定義了多入口的html文件名

clipboard.png

webpack config部分 主要注意HTMLPlugins,Entries,chunks三個

let HTMLPlugins = []
let Entries = {}
let chunks = []

config.HTMLDirs.forEach((page) => {
  const htmlPlugin = new HtmlWebpackPlugin({
    filename: `${page}.html`,
    template: path.resolve(__dirname, `../src/html/${page}.html`),
    chunks: ['manifest','vendor', page],
    inject: true,
    ssUrl: config.dev.SS_URL
  });
  HTMLPlugins.push(htmlPlugin);
  Entries[page] = path.resolve(__dirname, `../src/js/${page}.js`);
})

//其他配置
plugins:[
// 其他配置
...HTMLPlugins,
new webpack.optimize.CommonsChunkPlugin({
  name: 'manifest',
  minChunks: Infinity
}),
new webpack.optimize.CommonsChunkPlugin({
  name: 'vendor',
  chunks: chunks,
  minChunks:3
}),
]

至于login跳轉(zhuǎn)到index,直接window.location.href = 'index.html' 就可以了,因為就是簡單的頁面跳轉(zhuǎn)了,不存在頁面路由什么的

2017年6月9日 04:42