const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const pagesConfig = [{
    entry: 'src/views/test/static/js/index.js',
    template: 'src/views/test/index.html'
}]

const entrys = {
    common: './src/commons/common.js'
}

const htmlPlugin = []

pagesConfig.forEach(function({ entry, template }){
    const keys = entry.split('/')[2]
    entrys[keys] = `./${entry}`
    htmlPlugin.push(new HtmlWebpackPlugin({
        template: path.resolve(__dirname, `../${template}`),
        filename: `${keys}.html`,
        chunks: ['common', `${keys}`]
    }))
})

module.exports = {
    entrys,
    htmlPlugin
}