V
V
Vasily Vasilyev2018-06-24 22:53:20
webpack
Vasily Vasilyev, 2018-06-24 22:53:20

Does webpack include ALL css files for every html page?

I'm trying to switch to webpack, I created a config for a build of two pages, each with its own css style file with a unique name.
Problem: When building, both css files are connected to each html at once, despite the fact that in the js file of each page I import only one file.
Config:

plugins: [
        new HtmlWebpackPlugin({
            filename: 'index.html',
            template: path.resolve(PATH.source.pages, 'home/home.pug')
        }),
        new HtmlWebpackPlugin({
            filename: 'pages/about.html',
            template: path.resolve(PATH.source.pages, 'about/about.pug')
        }),
        new ExtractTextPlugin({
            filename: "styles-[name].css",
            ignoreOrder: true,
            allChunks: true
        }),
    ],

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Taratin, 2018-06-25
@Basil_Dev

new HtmlWebpackPlugin({
    filename: 'index.html',
    template: path.resolve(PATH.source.pages, 'home/home.pug'),
    chunks: ['<тут имена необходимых чанков - например index>']
})

Further all this business is added through a cycle to an array of plug-ins.
https://github.com/jantimon/html-webpack-plugin#options

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question