Use immutable updates for CSS loader configuration

Open
#681 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript, webpack
Domain
build-system

Research direction

Start in config/webpack/commonWebpackConfig.js at lines 49-61 and 80-96, then compare the immutable pattern in serverWebpackConfig.js. Update the CSS and Sass loader configuration so nested options are not mutated directly. Verify that the webpack configuration preserves the intended loader settings without modifying shared defaults.

Written by the indexing model from the issue text.

Description

enhancement

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).

Dominant language
JavaScript
Stars
1.7k
Forks
370
Avg merge
2d 15h
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from shakacode/react-webpack-rails-tutorial

All issues in shakacode/react-webpack-rails-tutorial

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.