在尝试构建开发版以及向项目添加打字稿文件后,我一直收到此错误。
Module build failed (from ./node_modules/ts-loader/index.js):
Error: Debug Failure. False expression.
我已经尝试过 npm我的打字稿,但仍然遇到相同的错误。
package.json
{
"name": "webpack-demo",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"build": "webpack -d"
},
"devDependencies": {},
"dependencies": {
"@types/node": "^10.5.1",
"css-loader": "^0.28.11",
"global": "^4.3.2",
"node-sass": "^4.9.1",
"sass-loader": "^7.0.3",
"style-loader": "^0.21.0",
"ts-loader": "^4.4.2",
"typescript": "^2.9.2",
"webpack": "^4.15.1",
"webpack-cli": "^3.0.8"
}
}
webpack.config.js
const path = require('path');
var webpack = require('webpack');
module.exports = {
entry: './src/index.ts',
mode: 'production',
module: {
rules: [{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
exclude: /node_modules/
}
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js','.css','.scss']
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'main.js'
}
}
答案 0 :(得分:0)
从mode: 'production'
中删除webpack.config.js
似乎可以解决问题,但是随后必须在构建脚本中添加-d
。