const path = require('path')
// json 解析
const yaml = require('yaml')
const json5 = require('json5')
const toml = require('toml')
module.exports = {
entry: './src/index.js', // 入口
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js' // 出口
},
module: {
rules: [
{
test: /\.css$/i, // css
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource', // image
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource' // 字体图标
},
{
test: /\.(csv|tsv)$/i,
use: ['csv-loader'] // csv
},
{
test: /\.xml$/i,
use: ['xml-loader'] // xml
},
{
test: /\.toml$/i, // json
type: 'json',
parser: {
parse: toml.parse
}
},
{
test: /\.yaml$/i, // json
type: 'json',
parser: {
parse: yaml.parse
}
},
{
test: /\.json5$/i, // json5
type: 'json',
parser: {
parse: json5.parse
}
}
]
}
}