【笔记】Webpack打包Toml文件

前言

Webpack打包Toml文件

下载依赖

1
npm install -D toml

修改配置文件

webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const toml = require("toml");

module.exports = {
module: {
rules: [
{
test: /\.toml$/,
type: "json",
parser: {
parse: toml.parse,
}
}
]
}
}

引入Toml文件

  • 引入Toml文件,得到JS对象
1
2
3
import data from "./data.toml"

console.log(data); // {}

完成