new HtmlWebpackScriptInjectPlugin({
// Файл со скриптом для конкретной страницы
filesWithScripts: ['../scripts/scriptForMainPage'],
append: true,
// Название файла, в который нужно вставить ссылку на скрипт
destinationFiles: ['./views/main_page.njk']
})
]
const testArr2 = [
new HtmlWebpackPlugin({
template: `./templates/pages/test.ejs`,
filename: `./views/test.njk`,
chunks: ['index', 'chunk1']
}),
new HtmlWebpackInjector(),
new HtmlWebpackPlugin({
template: `./templates/pages/test2.ejs`,
filename: `./views/test2.njk`,
chunks: ['index', 'chunk2']
}),
new HtmlWebpackInjector()
]
export default {
context: path.resolve(__dirname, 'source'),
entry: {
index: './entry.js',
chunk1: './templates/pages/chunk1.js',
chunk2: './templates/pages/chunk2.js'
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'public'),
},
plugins: [
new CleanWebpackPlugin(),
new MiniCssExtractPlugin({
filename: 'style.css'
}),
...testArr2
< some code >
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
minified: false
}
}
},