我有一个包含一些翻译的 YAML 文件。我需要将这些文件转换为 JSON 文件。我尝试过使用yaml-import-loader
and json-loader
但我收到错误。
这是我的设置:
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractEnglish = new ExtractTextPlugin('lang/en.js');
module.exports = {
entry: [
'./src/locales/application.en.yml',
],
output: {
filename: 'english.js',
},
module: {
strictExportPresence: true,
rules: [
{
test: /\.en\.yml$/,
use: extractEnglish.extract({
use: [
// { loader: 'json-loader' },
{
loader: 'yaml-import-loader',
options: {
output: 'json',
},
}],
}),
},
],
},
plugins: [
extractEnglish,
],
};
我得到的错误是:
Users/xxx/Documents/Project/node_modules/extract-text-webpack-plugin/dist/index.js:188
chunk.sortModules();
^
TypeError: chunk.sortModules is not a function
at /Users/xxx/Documents/Project/node_modules/extract-text-webpack-plugin/dist/index.js:188:19
无论是否相同的错误json-loader
是否评论。
我真的不明白出了什么问题。
版本:
“webpack”:“2.6.1”,
"extract-text-webpack-plugin": "^3.0.0",
"json-loader": "^0.5.7",