...
"devDependencies": {
"@types/node": "^16.0.0",
"@types/webpack": "^5.28.0",
"ts-node": "^10.0.0",
"tsconfig-paths": "^3.10.1",
"typescript": "^4.3.5",
"webpack": "^5.43.0",
"webpack-cli": "^4.7.2"
},
...
loader 用于对模块的源代码进行转换。用于在 import 其他模块时与处理文件
加载静态资源
import path from ‘path‘
import webpack from ‘webpack‘
const config: webpack.Configuration = {
entry: {
main: ‘./src/index.js‘,
},
output: {
path: path.resolve(__dirname, ‘public‘),
filename: ‘bundle.js‘,
},
module: {
rules: [
{
test: /\.css/,
use: [{ loader: ‘style-loader‘ }, { loader: ‘css-loader‘ }],
},
{ test: /\.ts/, use: ‘ts-loader‘ },
{ test: /\.(png|svg|jpg|gif)$/, use: [‘file-loader‘] },
],
},
}
export default config
原文:https://www.cnblogs.com/wangzx1973/p/14984002.html