Dynamically setting build options with @nx/angular:webpack-browser executor

319 Views Asked by At

A project I work on was just migrated to NX workspace and I’m facing some challenges to implement custom logic we have to set global styles options dynamically on NX. Previous implementation was using ngx-build-plus and with a pre hook defined in the config file we were able to set options.styles array like below:

export default {
    pre(options) {
        options.styles: buildStyles()
    }
}

buildStyles() returns the styles array to be bundled with the application.

With NX, we changed the executors to @nx/angular:webpack-browser in order to pass custom webpack config, but couldn’t find a way to set global styles from build options. Passing them in project.json styles array works fine and they are bundled but we need this list to be passed dynamically to the executor options as the list is big and configurable.

0

There are 0 best solutions below