webpack 错误:在我的 ASP.net + Vue 应用程序中需要 output.filename

编程入门 行业动态 更新时间:2024-10-28 20:29:11
本文介绍了webpack 错误:在我的 ASP + Vue 应用程序中需要 output.filename的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-26 22:51:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1142877.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   错误   ASP   webpack   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!