shakacode / shakapacker

Use Webpack to manage app-like JavaScript modules in Rails
MIT License
417 stars 91 forks source link

Update outdated webpack configuration example #455

Closed Judahmeek closed 6 months ago

Judahmeek commented 6 months ago

The configuration change example is broken.

const svgRule = config.module.rules.find(rule => rule.test.test('.svg')); only works if rule.test is a RegExp (because of the call to rule.test.test).

svgRule.test = svgRule.test.filter(t => !t.test('.svg')) only works if svgRule.test is an array (because of the call to svgRule.test.filter).

My guess is that this error was introduced because the same commit that created this example also changed that asset file's rule.test from arrays of RegExp to a single RegExp with conditional logic.

This PR addresses that & also slightly expands on possible rule changes.

For even more possible configuration change logic, see #453