Last active
July 15, 2017 11:42
Possible webpack-blocks API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'] | |
} | |
]) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Utility functions to pass into the block (2nd param): (Draft)
merge()
addLoader()
addPlugin()