Skip to content

Webpack 2 and plugin loading #149

@igl

Description

@igl

Problem

Using the options object (stylus: { ... }) in webpack2 fails. They validate the config with a schema now.

Invalid configuration object.
Webpack has been initialised using a configuration object that does not match the API schema.
- configuration has an unknown property 'stylus'....

Fix

Loaders should be updated to allow passing options via loader options in module.rules.

and/or

allow strings passed to use. Like: stylus?use=nib

Workaround 1

My workaround was to use the loader-string to inject options: stylus-loader?' + JSON.stringify(stylusOpts)

This works nicely however i can't use "use" this way:

Module build failed: Error: Plugin should be a function

Workaround 2

Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
plugins: {
new webpack.LoaderOptionsPlugin({
  options: {
    stylus: ...
  }
})

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