get error when pass function to pug
Closed this issue · 7 comments
I wanna pass a function to pug, and using pug-html-loader to load pug,
in webpack.config.js
{
test:/\.pug$/,
exclude: ['/node_modules/'],
loader: 'pug-html-loader',
query: {
data: {bb:function(str){return str + '444';},aa:'666'},
pretty: true
}
},
in pug file
p!= data.aa
p!= data.bb(data.aa)
use data.aa
is OK, but get error when use data.bb
Html Webpack Plugin:
Error: Child compilation failed:
Module build failed: TypeError: data.bb is not a function
- TypeError: data.bb is not a function
- compiler.js:76
[resume]/[html-webpack-plugin]/lib/compiler.js:76:16
- Compiler.js:214 Compiler.
[lib]/[webpack]/lib/Compiler.js:214:10
- Compiler.js:403
[lib]/[webpack]/lib/Compiler.js:403:12
- Tapable.js:67 Compiler.next
[lib]/[webpack]/[tapable]/lib/Tapable.js:67:11
- CachePlugin.js:40 Compiler.
[lib]/[webpack]/lib/CachePlugin.js:40:4
- Tapable.js:71 Compiler.applyPluginsAsync
[lib]/[webpack]/[tapable]/lib/Tapable.js:71:13
- Compiler.js:400 Compiler.
[lib]/[webpack]/lib/Compiler.js:400:9
- Compilation.js:577 Compilation.
[lib]/[webpack]/lib/Compilation.js:577:13
- Tapable.js:60 Compilation.applyPluginsAsync
[lib]/[webpack]/[tapable]/lib/Tapable.js:60:69
- Compilation.js:572 Compilation.
[lib]/[webpack]/lib/Compilation.js:572:10
- Tapable.js:60 Compilation.applyPluginsAsync
[lib]/[webpack]/[tapable]/lib/Tapable.js:60:69
- Compilation.js:567 Compilation.
[lib]/[webpack]/lib/Compilation.js:567:9
- Tapable.js:60 Compilation.applyPluginsAsync
[lib]/[webpack]/[tapable]/lib/Tapable.js:60:69
- Compilation.js:563 Compilation.
[lib]/[webpack]/lib/Compilation.js:563:8
- Tapable.js:60 Compilation.applyPluginsAsync
[lib]/[webpack]/[tapable]/lib/Tapable.js:60:69
- Compilation.js:525 Compilation.seal
[lib]/[webpack]/lib/Compilation.js:525:7
Does data.aa
work?
Does the pug loader support functions?
I'm not sure, but I only get this error message in Html Webpack Plugin, right? so I think the problem is in here, and not to report issues to pug-html-loader
I don't know the pug-html-loader well enough to help you with this.. I doubt that this is an html-webpack-plugin issue
I also submit an issue to pug-html-loader, I really wanna solve this bug, thx for your help.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.