Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extensions option to enable configurable file extension matching #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

i-like-robots
Copy link

@i-like-robots i-like-robots commented Apr 18, 2019

Sometimes it is useful to resolve files from bower.main: [] which are not JS files. This PR adds an extensions option which enables the configuration of the file extension/s to match.

Example use case

The latest versions of the sass-loader package (7.x) builds upon more of Webpack's module resolution algorithm rather than following the simple algorithm built into node-sass.

https://github.com/webpack-contrib/sass-loader/blob/master/CHANGELOG.md#700-2018-04-13

This means to use sass-loader effectively you usually need to add some extra resolve configuration to the Sass rule in order to resolve .scss and .sass files:

rules: [
  {
    test: [/\.s(c|a)ss$/],
    resolve: {
      extensions: ['.scss', '.sass']
    },
    use: [ 'sass-loader' ]
  }
]

However when using the new sass-loader package with this plugin to help resolve packages installed using Bower currently only .js files will be matched so setting the file extension as shown above has no effect.

My changes are intended to make it possible to use this plugin in situations like this where I want to resolve non-JavaScript files, e.g.:

rules: [
  {
    test: [/\.s(c|a)ss$/],
    resolve: {
      plugins: [ new BowerResolvePlugin({ extensions: ['.scss', '.sass'] }) ],
      extensions: ['.scss', '.sass']
    },
    use: [ 'sass-loader' ]
  }
]

I hope this makes sense! This is only a suggestion, if you are happy with it then I will update the readme as well.

cc webpack-contrib/sass-loader#556

@JakeChampion
Copy link

Hi @linaspasv, is there any chance this could get merged in at all? :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants