Skip to content

Instantly share code, notes, and snippets.

@andywer
Last active July 15, 2017 11:42
Possible webpack-blocks API
// With merge helper:
module.exports = function exampleBlock () {
return (context, { merge }) => merge({
module: {
rules: [
{
test: context.fileType('text/css'),
use: ['sample-css-loader']
}
]
}
})
}
// With addLoader helper:
module.exports = function exampleBlock () {
return (context, { addLoader }) => addLoader({
test: context.fileType('text/css'),
use: ['sample-css-loader']
})
}
// Without merge helper:
module.exports = function exampleBlock () {
return context => config => ({
...config,
module: {
...config.module,
rules: config.module.rules.concat([
{
test: context.fileType('text/css'),
use: ['sample-css-loader']
}
])
}
})
}
@andywer
Copy link
Author

andywer commented Feb 28, 2017

Utility functions to pass into the block (2nd param): (Draft)

  • merge()
  • addLoader()
  • addPlugin()

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