I'm just trying to load an HTML file so I can use it as a component in react. I've tried all sorts of configurations in webpack.config.js, I've tried reinstalling html-loader, and I've looked at every tutorial/bug post I could find with no luck solving my issue.
webpack.config.js
{
test: /\.html$/,
use: {
loader: 'html-loader',
options: {
attrs: [':data-src']
}
}
},
package.json
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.2.3",
"@babel/preset-react": "^7.0.0",
"classnames": "^2.2.6",
"css-loader": "^2.1.0",
"html-loader": "^0.5.5",
"style-loader": "^0.23.1",
"webpack": "^4.19.1",
"webpack-cli": "^3.2.1"
},
"babel": {
"presets": [
"@babel/env",
"@babel/react"
]
}
index.jsx
import test from './test.html'
Error
./src/test.html 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
> <h1>Hello, world!</h1>