问题描述
限时送ChatGPT账号..我是 webpack 的初学者,目前我正在关注@Bert this 的回答,以在我当前的MVC 4 应用程序.
I am a beginner with webpack and currently I am following this answer by @Bert, to configure Vue inside my current MVC 4 application.
当我尝试运行 webpack --watch
时出现以下错误:
when I try to run webpack --watch
I get the following error:
Error: 'output.filename' is required, either in config file or as --output-filename
at processOptions (dir\node_modules\webpack\bin\convert-argv.js:507:11)
at processConfiguredOptions (dir\node_modules\webpack\bin\convert-argv.js:150:4)
at module.exports (dir\node_modules\webpack\bin\convert-argv.js:112:10)
at yargs.parse (dir\node_modules\webpack\bin\webpack.js:171:41)
at Object.Yargs.self.parse (dir\node_modules\webpack\node_modules\yargs\yargs.js:533:18)
at Object.<anonymous> (dir\node_modules\webpack\bin\webpack.js:152:7)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
我的 webpack.config.js 文件:
my webpack.config.js file:
const fs = require("fs");
const path = require("path");
// build an object that looks like
// {
// "filename": "./filename.vue"
// }
// to list the entry points for webpack to compile.
function buildEntry() {
const reducer = function(entry, file) { entry[file.split(".").shift()] = './Vue/' + file; return entry; };
return fs.readdirSync(path.join(__dirname, "Vue"))
.filter(function(file) {file.endsWith(".vue")})
.reduce(reducer, {});
}
module.exports = {
entry: buildEntry(),
output: {
path: path.join(__dirname, "Vue"),
filename: "[name].js",
library: "[name]"
},
module: {
loaders: [
{ test: /\.vue$/, loader: 'vue-loader' },
]
}
}
我刚刚用 ES5 更改了 ES6 代码,我也遵循了一些关于该问题的现有 SO 答案,但这些答案都不适用,我想我在这里遗漏了一些明显的东西.
I just changed ES6 code with ES5, I also followed some existing SO answers regarding the issue but none of those are applicable, I guess I am missing something obvious here.
推荐答案
reducer 转 ES5 时,引入了一个 bug.
When the reducer was converted to ES5, a bug was introduced.
return fs.readdirSync(path.join(__dirname, "Vue"))
.filter(function(file) {file.endsWith(".vue")})
.reduce(reducer, {})
具体来说,
function(file) {file.endsWith(".vue")}
应该是
function(file) { return file.endsWith(".vue") }
这篇关于webpack 错误:在我的 ASP + Vue 应用程序中需要 output.filename的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论