【问题标题】:Error: No loader specified configuring vue.config.js错误:没有指定加载程序来配置 vue.config.js
【发布时间】:2018-09-10 17:23:33
【问题描述】:

使用 vue-cli3 并尝试通过 fetch 命令加载 csv 文件,我已经像这样配置了 vue.config.file

module.exports = {
  chainWebpack: config => {
    config.module
      .rule('csv')
      .use('file-loader')
  }
}

并得到错误:

 INFO  Starting development server...
 ERROR  Error: No loader specified
Error: No loader specified
    at Function.normalizeUseItem (D:\Learn\d3\d3-projects\node_modules\webpack\lib\RuleSet.js:274:10)
    at Function.normalizeUse (D:\Learn\d3\d3-projects\node_modules\webpack\lib\RuleSet.js:236:19)
    at use.map (D:\Learn\d3\d3-projects\node_modules\webpack\lib\RuleSet.js:233:33)
    at Array.map (<anonymous>)
    at Function.normalizeUse (D:\Learn\d3\d3-projects\node_modules\webpack\lib\RuleSet.js:233:6)
    at Function.normalizeRule (D:\Learn\d3\d3-projects\node_modules\webpack\lib\RuleSet.js:184:26)
    at rules.map (D:\Learn\d3\d3-projects\node_modules\webpack\lib\RuleSet.js:86:20)
    at Array.map (<anonymous>)
    at Function.normalizeRules (D:\Learn\d3\d3-projects\node_modules\webpack\lib\RuleSet.js:85:17)
    at new RuleSet (D:\Learn\d3\d3-projects\node_modules\webpack\lib\RuleSet.js:80:24)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

【问题讨论】:

    标签: javascript webpack vue-cli


    【解决方案1】:

    根据https://www.npmjs.com/package/webpack-chain,您所做的是创建了一个“命名使用”,但尚未定义关联的加载器。配置模块似乎需要按特定顺序调用函数,这可能不是很直观:

      chainWebpack: config => {
        config.module
          .rule("html")            //create a named rule
          .test(/web-components/)  //define the file test
          .use("html-loader")      //create a named use
          .loader("html-loader")   //assign a loader
          .end();                  //back up to define another use, e.g. you could do .end().use()....
    }
    

    【讨论】:

      猜你喜欢
      • 2021-09-20
      • 2022-07-03
      • 2021-04-19
      • 1970-01-01
      • 2020-05-28
      • 2021-02-26
      • 2019-12-17
      • 2020-09-28
      相关资源
      最近更新 更多