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

Respect exclude option when handling url #779

Closed
rodfersou opened this issue Oct 1, 2018 · 11 comments · Fixed by #856
Closed

Respect exclude option when handling url #779

rodfersou opened this issue Oct 1, 2018 · 11 comments · Fixed by #856

Comments

@rodfersou
Copy link

rodfersou commented Oct 1, 2018

Is it possible to respect exclude option when handling url?

I have a specific use case, in our CMS an url that has '++resource++' inside should be considered external image. This is my current configuration:

     {
        // Handle SCSS files
        test: /\.scss$/,
        exclude: /\+\+resource\+\+/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: [
            'css-loader',
            'postcss-loader',
            'sass-loader'
          ]
        }),
      },

But the url handling is not respecting this configuration, and throw this traceback:

    ERROR in ./node_modules/css-loader!./node_modules/postcss-loader/lib!./node_modules/sass-loader/lib/loader.js!./app/cover.scss
    Module not found: Error: Can't resolve './++resource++plone.app.jquerytools.pb_close.png' in '/home/rodfersou/.projects/collective.cover/webpack/app'
     @ ./node_modules/css-loader!./node_modules/postcss-loader/lib!./node_modules/sass-loader/lib/loader.js!./app/cover.scss 7:6933-6992
@alexander-akait
Copy link
Member

@rodfersou please use exclude on file-loader/url-loader. Can you create minimum reproducible test repo?

@rodfersou
Copy link
Author

@evilebottnawi here you are https://github.com/rodfersou/exclude-in-url

just run:

$ npm install
$ npm run debug

and the error will happen

@rodfersou
Copy link
Author

I tried to use file-loader/url-loader without success, any help would be appreciated.

@alexander-akait
Copy link
Member

@rodfersou yep, it is impossible right now, we prepare css-loader@2 #760 and can implement this after release

@rodfersou
Copy link
Author

@evilebottnawi great, I look forward to it

@rodfersou
Copy link
Author

Thank you very much!

@rodfersou
Copy link
Author

@evilebottnawi could you please provide an example on how to make this feature work? I just updated the version (in the same PR mentionated) and still get a traceback.

@rodfersou
Copy link
Author

Okay, I could figure out what was missing, but still for me looks like the result of the function should be inverted to keep in mind the same behavior when it is a boolean..
I mean when the function return false should not look the url.
This is my configuration in the end:

    {
      test: /\.scss$/,
      use: ExtractTextPlugin.extract({
        fallback: 'style-loader',
        use: [
          {
            loader: 'css-loader',
            options: {
              url: (url, resourcePath) => /\+\+resource\+\+/.test(url)
            }
          },
          'postcss-loader',
          'sass-loader'
        ]
      }),
    },

@rodfersou
Copy link
Author

thank you very much

@alexander-akait
Copy link
Member

@rodfersou can you open issue?

@rodfersou
Copy link
Author

@evilebottnawi #891

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

Successfully merging a pull request may close this issue.

2 participants