Skip to content

Multiple configurations for webpack #252

@ghost

Description

Hi,

I have seen that it is possible to have multiple configurations in the webpack.config.js, just like magic :

Encore
    .setOutputPath('web/build/')
    .setPublicPath('/build')
    .addEntry('app', './assets/js/main.js')
    .addStyleEntry('global', './assets/css/global.scss')
    .enableSassLoader()
    .autoProvidejQuery()
    .enableSourceMaps(!Encore.isProduction())
;

// build the first configuration
const firstConfig = Encore.getWebpackConfig();

// Reset Encore to build the second config
Encore.reset();

Encore
    .setOutputPath('web/build/')
    .setPublicPath('/build')
    .addEntry('mobile', './assets/js/mobile.js')
    .addStyleEntry('mobile', './assets/css/mobile.less')
    .enableLessLoader()
    .enableSourceMaps(!Encore.isProduction())
;

// build the second configuration
const secondConfig = Encore.getWebpackConfig();

// export the final configuration
module.exports = [firstConfig, secondConfig];

But I want to know if it is possible to run one config with a specific option, like
yarn run encore dev --firstConfig

Thank you for your answer

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions