Answer the question
In order to leave comments, you need to log in
Why does it throw an error when I run build?
I have a src.ts folder with script.ts and index.html files.
In index.html I have
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Webpack</title>
</head>
<body>
<canvas id="canvas"></canvas>
</body>
</html>
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: './src.ts/script.ts',
output:{
filename: 'bundle.[hash].js',
path: path.resolve(__dirname, '..', 'dist.ts')
},
resolve: {
extensions:[
'.ts',
'.js'
]
},
plugins: [
new HtmlWebpackPlugin({
filename: "index.html",
template: './src.ts/index.html'
})
],
module: {
rules: [
{
test: /\.ts/,
loader: 'ts-loader',
include: path.resolve()
}
]
}
}
Answer the question
In order to leave comments, you need to log in
You have a clear error:
ERROR in Error: C:\Users\Aspire 3\Desktop\error-handling\src.ts\index.html:94
var canvas = document.getElementById('canvas');
^
ReferenceError: document is not defined
if(global.document){
....
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question