Last active
July 15, 2017 11:42
-
-
Save andywer/4bdd9f4e5b3e6d4b94a1f4d843304dc4 to your computer and use it in GitHub Desktop.
Possible webpack-blocks API
This file contains hidden or 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'] | |
| } | |
| ]) | |
| } | |
| }) | |
| } |
Author
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()