htmlファイルをインポートしてjsonに変換したい。
const DocHtml = require('../../Shared/assests/index.html');
const template = { __html: DocHtml };
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.html$/,
use: {
loader: 'html-loader',
options: {
attrs: [':data-src']
}
}
},
],
},
};
しかし、それはエラーを発生させます...
./src/User/Shared/assests/index.html 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <html xmlns="http://www.w3.org/1999/xhtml">
| <head>