Skip to content

url in query is handled incorrect while writing custom loader #1466

Closed

Description

@leftstick

Once i want to develop a custom loader which can receive an JSON options in the query as following:

var urls = JSON.stringify({
    value: {
        cdnUrl: 'http://xxx.domain.com/imgs/'
    }
});

module.exports = {
    entry: {
        index: path.resolve(__dirname, 'public', 'js', 'index.js')
    },
    output: {
        path: path.resolve(__dirname, '..', '..', '..', '..', 'public', 'build', 'js'),
        filename: '[name].bundle.js',
        chunkFilename: '[id].bundle.js',
        publicPath: '/build/js/'
    },
    module: {
        loaders: [
            {
                test: /\.scss$/,
                loader: 'my-custom-loader?' + urls
            }
        ]
    }
};

The thing i found is the this.query always remove one / right after http: from the passed options:

module.exports = function(source) {
    'use strict';
    this.cacheable && this.cacheable();
    console.log(this.query);//?{"value":{"cdnUrl":"http:/xxx.domain.com/imgs/"}}
};

Is this by design?

Activity

  1. sokra commented on Sep 22, 2015

    @sokra
    Member

    No. I don't think this is caused by webpack. It just passes the string to the loader.

  2. sokra commented on Sep 22, 2015

    @sokra
    Member

    Or maybe it's caused by the resolving stuff, which tries to eliminate duplicate path separators. Than it's a bug.

  3. leftstick commented on Sep 22, 2015

    @leftstick
    ContributorAuthor

    @sokra HI, do you have any suggestion about this issue? Thanks

  4. leftstick commented on Sep 23, 2015

    @leftstick
    ContributorAuthor

    And the \ will be replaced to / which is not expected. See following:

    var urls = JSON.stringify({
        options: {
            interpolate: {
                pattern: '%([\\s\\S]+?)%'
            }
        },
        value: {
            color: '#000'
        }
    });

    While passing this to loader, it should be ?{"options":{"interpolate":{"pattern":"%([\\\\s\\\\S]+?)%"}},"value":{"color":"#000"}}.

    But in fact, it is transformed to ?{"options":{"interpolate":{"pattern":"%([//s//S]+?)%"}},"value":{"color":"#000"}}

    Is there any clue for solving this?

  5. leftstick commented on Jun 30, 2016

    @leftstick
    ContributorAuthor

    There is still no fix or work around for this currently. So sad

  6. bebraw commented on Feb 1, 2017

    @bebraw
    Contributor

    Can someone confirm this on webpack 2?

  7. webpack-bot commented on Aug 11, 2017

    @webpack-bot
    Contributor

    This issue had no activity for at least half a year.

    It's subject to automatic issue closing if there is no activity in the next 15 days.

  8. added
    status: stale
    on Aug 11, 2017
  9. webpack-bot commented on Aug 26, 2017

    @webpack-bot
    Contributor

    Issue was closed because of inactivity.

    If you think this is still a valid issue, please file a new issue with additional information.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: stale

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions