//file build/webpack.base.conf.js
//entry 配置
module.exports = {
entry: {
app: './src/main.js'
},
//....
//file build/webpack.dev.conf.js
//html配置
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
})
//file build/webpack.base.conf.js
//entry 配置
module.exports = {
entry: {
'index': './src/view/index/index.js',
'login': './src/view/login/login.js',
},
//....
//file build/webpack.dev.conf.js
//html配置,index我们保留了根目录访问路径
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/view/index/index.html',
inject: true,
chunks: ['index']
}),
new HtmlWebpackPlugin({
filename: 'login/login.html', //http访问路径
template: './src/view/login/login.html', //实际文件路径
inject: true,
chunks: ['login']
})
var glob = require('glob')
function getEntry(globPath, pathDir) {
var files = glob.sync(globPath);
var entries = {},
entry, dirname, basename, pathname, extname;
for (var i = 0; i < files.length; i++) {
entry = files[i];
dirname = path.dirname(entry);
extname = path.extname(entry);
basename = path.basename(entry, extname);
pathname = path.join(dirname, basename);
pathname = pathDir ? pathname.replace(pathDir, '') : pathname;
console.log(2, pathname, entry);
entries[pathname] = './' + entry;
}
return entries;
}
//我们的key不是简单用的上一个代码的index,login而是用的index/index,login/login因为考虑在login目录下面还有register
//文件路径的\\和/跟操作系统也有关系,需要注意
var htmls = getEntry('./src/view/**/*.html', 'src\\view\\');
var entries = {};
var HtmlPlugin = [];
for (var key in htmls) {
entries[key] = htmls[key].replace('.html', '.js')
HtmlPlugin.push(new HtmlWebpackPlugin({
filename: (key == 'index\\index' ? 'index.html' : key + '.html'),
template: htmls[key],
inject: true,
chunks: [key]
}))
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有