B
B
bozedai2020-01-07 19:56:08
Frontend
bozedai, 2020-01-07 19:56:08

How to set up webpack to build multiple pages?

I want to split the code on the client into several separate bundles. What is the best way to do this?
Making an entry point for every page looks stupid. I want to have one entry point, like index.js, and do dynamic imports using require in it. But how to set up wepback to build something like this? At the output I want to get a separate js file for each page
const page = require("./pages/" + pageName)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2020-01-07
@delphinpro

Try sliptChunk along with magic comments https://webpack.js.org/api/module-methods/#magic-c...
These are not separate files, but dynamic import of separate files on the required pages.
And for some just the entry points are intended.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question