Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Requirejs "text!" plugin alternative to webpack

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?

like image 435
Dmitry Yaremenko Avatar asked Sep 27 '22 01:09

Dmitry Yaremenko


1 Answers

Should use 'text-loader': https://www.npmjs.com/package/text-loader

My mistake was that I used both text! notation in require and loaders config with "text-loader".

like image 75
Dmitry Yaremenko Avatar answered Nov 15 '22 04:11

Dmitry Yaremenko