-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
30 lines (24 loc) · 801 Bytes
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
exports.pages = function(env) {
const HtmlWebpackPlugin= require('html-webpack-plugin');
const fs = require('fs');
const path = require('path');
const appFolder = path.resolve(__dirname, './src/app/pages')
var pages = [];
fs.readdirSync(appFolder).forEach( view => {
const viewName = view.split('.')[0];
const options = {
fileName: `${viewName}/index.html`,
template: `src/app/pages/${view}`,
inject: true
};
if (env === 'development') {
options.minify = {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
};
}
pages.push(new HtmlWebpackPlugin(options));
});
return pages;
};