TypeError: text.forEach is not a function
HairyRabbit opened this issue · comments
Rabbit commented
Hi, I want to use json-loader
with ExtractTextPlugin
like this config:
rule: {
test: /\.json$/,
loader: ExtractJSON.extract({
loader: [{
loader: 'json-loader'
}]
})
}
That was throw this error:
ERROR in ./src/index.json
Module build failed: TypeError: text.forEach is not a function
at Object.<anonymous> (\node_modules\extract-text-webpack-plugin\loader.js:109:10)
at Compiler.<anonymous> (\node_modules\webpack\lib\Compiler.js:280:10)
at \node_modules\webpack\lib\Compiler.js:480:13
...
I change the json-loader return value as:
// json-loader/index.js
return "module.exports = " + '`' + JSON.stringify(value, undefined, "\t") + '`' + ";";
It's works fine, but I think it's not a good idea. Anything help for this problem ?
Thanks :)
Gijs Goudzwaard commented
I'm having the exact same problem and changing the return statement as stated above works for me aswell.
Michael Ciniawsky commented
@GijsGoudzwaard @yuffiy Mind sending a PR 😛 ?