Skip to content

stringify object to pass to loader #15

@dtothefp

Description

@dtothefp

I placed this issue webpack/sass-loader#155 on sass-loader but maybe it is more appropriate there. I'm trying to figure out how to stringify an object to be parsed by loader-utils. I tried using json5 directly with no luck, and tried encodeURIComponent on the stringified object but when it is parsed it is a string not an object. Is there some way to accomplish this?

let functions = {
  'image-url($filename)': function(filename) {
    var imageUrl = process.env.NODE_ENV === 'development' ?
      '' :
      '';//enter CDN path here
    var fileName = filename.getValue();

    var imagePath = 'url("' + imageUrl + '/' + fileName + '")';
    /*eslint-disable */
    return new sass.types.String(imagePath);
    /*eslint-enable */
  }
}

`sass-loader?functions=${somehowStringify(functions))}`
Update: got passing object as query param to work, but still found no way to do this programmatically by stringifying a series of objects

screen shot 2015-08-31 at 9 02 29 am

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions