webpack 找不到模块: Error: Can't resolve 'fs'
webpack.config.js, fs:'empty'只能够让报错不在控制台显示!!
```
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin'); // 通过 npm 安装
const fs = require('fs');
module.exports = {
// 向 entry 传入一个数组将创建“多个主入口(multi-main entry)”
entry: './src/main.js',
output: {
filename: 'bundle.js'
},
// node:{
// fs:'empty'
// },
module: {
rules: [
//在 require()/import 语句中被解析为 '.txt' 的路径时,先使用 raw-loader 转换后再打包
{ test: /\.txt$/, use: 'raw-loader' }
]
},
plugins: [
new HtmlWebpackPlugin({template: './public/index.html'})
]
};
```
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>index</h1>
<script src="/bundle.js"></script>
</body>
</html> fs是服务端库,无法在前端引用.
页:
[1]