Set multiple entries using react-app-rewired

879 Views Asked by At

Below are some options from an open-webpack (not CRA) react project:

// webpack.config.js

module.exports = {
    // ...
    entry: {
        main: './src/index.js',
        'editor.worker': 'monaco-editor/esm/vs/editor/editor.worker.js',
        'yaml.worker': 'monaco-yaml/lib/esm/yaml.worker.js',
    },
    // ...

How to implement similar configuration in config-overrides.js (using react-app-rewired)?

// config-overrides.js

module.exports = function override (config) {
    config.entry = // ???

    return config
}

My experience:

Simply set it to:

config.entry = {
    main: './src/index.js',
    'editor.worker': 'monaco-editor/esm/vs/editor/editor.worker.js',
    'yaml.worker': 'monaco-yaml/lib/esm/yaml.worker.js',
}

doesn't work. It even causes issues in loading index.js!

1

There are 1 best solutions below

0
On
config.optimization.runtimeChunk = 'single'

maybe help you ...

https://webpack.js.org/configuration/optimization/#optimizationruntimechunk