admin管理员组文章数量:1021857
How to make this work in webpack?
var templateHtml = require("text!templates/main.html");
console.log(templateHtml); // outputs string content of the "main.html" file
I need to migrate from requirejs + require-text plugin to webpack with minimum code changes so I need that loader in webpack... Have any suggestions?
How to make this work in webpack?
var templateHtml = require("text!templates/main.html");
console.log(templateHtml); // outputs string content of the "main.html" file
I need to migrate from requirejs + require-text plugin to webpack with minimum code changes so I need that loader in webpack... Have any suggestions?
Share Improve this question asked Aug 11, 2015 at 17:23 Dmitry YaremenkoDmitry Yaremenko 2,58022 silver badges31 bronze badges2 Answers
Reset to default 4Should use 'text-loader': https://www.npmjs./package/text-loader
My mistake was that I used both text!
notation in require
and loaders
config with "text-loader".
As the other answer mentions, use https://www.npmjs./package/text-loader. With Webpack 2.2, I also needed to add the following to the root of the Webpack config object:
resolveLoader: {
alias: {
// Support for require('text!file.json').
'text': 'full/path/to/node_modules/text-loader'
}
}
How to make this work in webpack?
var templateHtml = require("text!templates/main.html");
console.log(templateHtml); // outputs string content of the "main.html" file
I need to migrate from requirejs + require-text plugin to webpack with minimum code changes so I need that loader in webpack... Have any suggestions?
How to make this work in webpack?
var templateHtml = require("text!templates/main.html");
console.log(templateHtml); // outputs string content of the "main.html" file
I need to migrate from requirejs + require-text plugin to webpack with minimum code changes so I need that loader in webpack... Have any suggestions?
Share Improve this question asked Aug 11, 2015 at 17:23 Dmitry YaremenkoDmitry Yaremenko 2,58022 silver badges31 bronze badges2 Answers
Reset to default 4Should use 'text-loader': https://www.npmjs./package/text-loader
My mistake was that I used both text!
notation in require
and loaders
config with "text-loader".
As the other answer mentions, use https://www.npmjs./package/text-loader. With Webpack 2.2, I also needed to add the following to the root of the Webpack config object:
resolveLoader: {
alias: {
// Support for require('text!file.json').
'text': 'full/path/to/node_modules/text-loader'
}
}
本文标签: javascriptRequirejs quottextquot plugin alternative to webpackStack Overflow
版权声明:本文标题:javascript - Requirejs "text!" plugin alternative to webpack - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745482767a2152608.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论