Ho due moduli diversi, come gli studenti e il personale.
- Per gli studenti di file deve essere creato nella cartella dist con percorso statico /studenti -
publicPath: "/students/"
. - Per il personale di file deve essere creato nella cartella dist senza statico percorso(cartella principale).
Ho impostato il publicPath: "/students/"
ma il personale di file statici percorso anche incluso con gli studenti.
Ho aggiunto la config sotto
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
module.exports = {
entry: {
students: [
'./students/css/students.css',
'./students/js/students.js',
'./students/templates/students/index.pug'
],
staff: [
'./staff/css/index.css',
'./staff/js/index.js',
'./staff/templates/index.pug',
]
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
publicPath: "/students/"
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './students/templates/students/index.pug',
chunks: ['students'],
}),
new HtmlWebpackPlugin({
filename: 'staff.html',
template: './staff/templates/index.pug',
chunks: ['staff'],
})
]
};