N
N
Ninja Mate2016-03-16 21:11:18
JavaScript
Ninja Mate, 2016-03-16 21:11:18

How to set up the webpack CommonsChunkPlugin properly for a project?

I'm trying to set up a react project to connect scripts depending on the user's role.
there are production build settings

entry: [
    './src/index'
  ],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js',
    publicPath: '/static/'
  },

the project has src/admin/users.js which is not an entry point, but connects to one of the buttons and is accordingly assembled into bundle.js
It is not possible to embed this piece from the documentation correctly
new CommonsChunkPlugin({
            name: "admin-commons",
            chunks: ["adminPageA", "adminPageB"]
        }),
        new CommonsChunkPlugin({
            name: "commons",
            chunks: ["pageA", "pageB", "admin-commons.js"],
            minChunks: 2
        })

how to configure breakdown without an entry point (or do you need to make a separate application in the project itself)?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question