Pavel Poberezhnyi
Pavel Poberezhnyi

Reputation: 773

Webpack: How to find all files inside certain folder name

I have file tree like app/components/forms/components/formError/components I need to write a rule that tests all .scss files that are only inside root components or inside scene folder. How can I do this? The current rule is next:

{
      test: /.*\/(components|scenes)\/.*\.scss$/,
      use: [{
        loader: 'style-loader',
      }, {
        loader: 'css-loader',
        options: {
          modules: true,
          localIdentName: '[local]___[hash:base64:5]',
        },
      }, {
        loader: 'sass-loader',
      }],
    }

but it didn't find required files

Upvotes: 9

Views: 5627

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627419

You may use

/(components|scenes).*\.scss$/

Details

  • (components|scenes) - matches the first components or scenes substring
  • .* - any 0+ chars, as many as possible, up to the
  • \.scss$ - .scss at the end of the string.

See this regex demo.

Upvotes: 13

Related Questions