Skip to content

Use immutable updates for CSS loader configuration #681

@justin808

Description

@justin808

Issue

Currently in config/webpack/commonWebpackConfig.js:49-61, we directly mutate nested loader options:

if (cssLoader?.options?.modules) {
  cssLoader.options.modules.namedExport = false;
  cssLoader.options.modules.exportLocalsConvention = 'camelCase';
}

This risks affecting shared objects from Shakapacker's defaults.

Solution

Use object spread for immutability (already done correctly in serverWebpackConfig.js):

if (cssLoader?.options?.modules) {
  cssLoader.options.modules = {
    ...cssLoader.options.modules,
    namedExport: false,
    exportLocalsConvention: 'camelCase',
  };
}

Related

Similar pattern needed in Sass loader configuration (lines 80-96).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions