Sunday, 7 May 2017

How to create a custom loader for node/webpack with includes

tldr: How can we do the same as node-sass/sass-loader of watching scss files with webpack including child includes in a custom language?

If I have my own language:

main.foo

con.l "hello world from main"

#include "child.foo"

child.foo

con.l "hello world from child"

How can I set up a build similar to node-sass so that if child.foo changes, the whole thing is compiled again?

Is webpack the best way to go for this:

 module: {
     loaders: [{
         test: /\.foo$/,
         loader: 'foo-loader'
     }

I would like to use webpack as I do for my other projects, but how do you get the foo-loader to watch for changes in all the child includes when run with webpack -w?

I understand that I will need to implement custom parsing for the #include "child.foo" which is fine.



via tic

No comments:

Post a Comment