【发布时间】:2019-02-02 07:43:15
【问题描述】:
webpack 在 bundle 中包含 .json 文件
我试试这个
const data = require('./header.json');
如果我使用 json-loader
{
test: /\.json?$/,
loader: 'json-loader',
options: {
name: '[hash].[ext]',
publicPath: assetsPath + 'constants/',
outputPath: 'assets/json',
},
},
然后我收到以下错误 模块解析失败:在 'module.exports = {"l...' 您可能需要适当的加载程序来处理此文件类型。
我需要在构建后我可以更改 json 文件
【问题讨论】:
-
您确定您的
json有效吗? -
是的,json有效
标签: webpack