web-xiangsonghua/dwt-ems/webpack-ems/webpack.html.js
2024-12-23 15:13:57 +08:00

88 lines
1.9 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let fs = require('fs');
let path = require('path');
let HtmlWebpackPlugin = require('html-webpack-plugin');
let ExtractTextPlugin = require('extract-text-webpack-plugin');
let HtmlWebpackLayoutPlugin = require('html-webpack-layout-plugin');
//------------------------------
// 读取src/js下的页面入口目录
// 除了common和lib外都是各个页面对应的目录
// 构建HtmlWebpackPlugin对象以创建页面
// 其中页面filename为{{目录名称}}.html
// 页面模板为src/view/{{目录名称}}.html
// 页面的chunks只有一个就是[{{目录名称}}]
//------------------------------
let files = fs.readdirSync('./src/js');
let plugins = [];
// 配电室基本信息
const prBaseInfoLayoutPages = [
'pr-material',
'pr-inspection-log',
'pr-repair-log',
'pr-check-list',
'pr-sign',
'real-time-data',
'real-time-data-new',
'history-data',
'report-setting',
'pr-table-setting',
// Add start 2018/10/9 10:17 kangzhi
'alarm-pusher-setting',
// Add end 2018/10/9 10:17 kangzhi
'compare-energy',
'time-energy',
'report',
];
// 不需要模板的页面
const purePage = [
'privilege-error',
'404',
'login'
];
files.forEach((file) => {
if (file === 'common' || file === 'lib' || file === 'utils' ) {
return;
}
// http://ems.dianwutong.com:8080/history-data.html?id=70&custype=null
// if(file!= 'warning-detail' && file!= 'system-warning') {
// return;
// }
let filename = (file + '.html');
let opts = {
title: 'EMS-电务通',
inject: 'body',
filename: filename,
template: ('./src/view/' + file + '.html'),
chunksSortMode: 'manual',
chunks: ['common',file],
hash: true
};
if (purePage.indexOf(file) > -1) {
} else if (prBaseInfoLayoutPages.indexOf(file) > -1) {
opts.layout = ('./src/view/common/prBaseInfo-layout.html');
} else {
opts.layout = ('./src/view/common/layout.html');
}
plugins.push(new HtmlWebpackPlugin(opts));
});
plugins.push(new HtmlWebpackLayoutPlugin());
module.exports = plugins;