Após incluir os loaders de style, html e png o webpack deu um erro ao executar o comando npm run build.
O que pode ser??
/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js?:93
var style = document.createElement('style');
^
ReferenceError: document is not defined
- injectStylesIntoStyleTag.js?:93 insertStyleElement
[.]/[style-loader]/dist/runtime/injectStylesIntoStyleTag.js?:93:15
package.json
{
"name": "05-spa-javascript",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "npm run build && webpack-dev-server --config ./webpack.config.js --mode development",
"build": "webpack --config webpack.config.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"css-loader": "^3.5.2",
"file-loader": "^6.0.0",
"html-loader": "^1.1.0",
"html-webpack-plugin": "^4.2.0",
"style-loader": "^1.1.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
}
}
webpack.config.js
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
mode: "development",
devServer: {
open: true,
contentBase: "dist"
},
entry: "./src/componentes/lista/listagem-cliente.js",
output: {
filename: "main.js",
path: path.resolve(__dirname, "dist")
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/clientes.html",
fielname: "index.html"
})
],
module: {
rules: [
{
test: /\.css$/i,
use: ["style-loader", "css-loader"]
}, {
test: /\.html$/,
use: ["html-loader"]
}, {
test: /\.png$/,
use: {
loader: "file-loader",
options: {
name: "[name].[ext]"
}
}
}
]
}
}