Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack: How to find all files inside certain folder name

Tags:

regex

webpack

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

like image 734
Pavel Poberezhnyi Avatar asked Feb 26 '18 11:02

Pavel Poberezhnyi


Video Answer


1 Answers

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.

like image 66
Wiktor Stribiżew Avatar answered Sep 23 '22 10:09

Wiktor Stribiżew