Skip to content
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
This repository was archived by the owner on Aug 28, 2026. It is now read-only.

Respect exclude option when handling url #779

Closed

Description

@rodfersou

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

Activity

  1. alexander-akait commented on Oct 1, 2018

    @alexander-akait
    Member

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

  2. rodfersou commented on Oct 1, 2018

    @rodfersou
    Author

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

    just run:

    $ npm install
    $ npm run debug

    and the error will happen

  3. rodfersou commented on Oct 1, 2018

    @rodfersou
    Author

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

  4. alexander-akait commented on Oct 1, 2018

    @alexander-akait
    Member

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

  5. rodfersou commented on Oct 2, 2018

    @rodfersou
    Author

    @evilebottnawi great, I look forward to it

  6. modified the milestones: 2.0.0, 2.1.0 on Dec 5, 2018
  7. rodfersou commented on Dec 8, 2018

    @rodfersou
    Author

    Thank you very much!

  8. rodfersou commented on Dec 30, 2018

    @rodfersou
    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.

  9. rodfersou commented on Dec 30, 2018

    @rodfersou
    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'
            ]
          }),
        },
  10. rodfersou commented on Dec 30, 2018

    @rodfersou
    Author

    thank you very much

  11. alexander-akait commented on Jan 4, 2019

    @alexander-akait
    Member

    @rodfersou can you open issue?

  12. rodfersou commented on Feb 6, 2019

    @rodfersou
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions