解决webpack打包报错 No module factory available for dependency type: CssDependency

在使用vuecl3打包时遇到的错误,做一下笔记

问题描述:在打包过程出现 没有可用于依赖类型的模块 CssDependency

在vue.config.js中添加

module.exports = {
  css: {
    extract: false
  }
};

  

我也查找到了相对应的文档, 发现有些还是不能理解的, 也不清楚怎么会发生这种, 之前好好的, 突然就不可以打包了

原文如下:

css.extract
Type: boolean | Object

Default: true in production, false in development

Whether to extract CSS in your components into a standalone CSS files (instead of inlined in JavaScript and injected dynamically).

This is always disabled when building as web components (styles are inlined and injected into shadowRoot).

When building as a library, you can also set this to false to avoid your users having to import the CSS themselves.

Extracting CSS is disabled by default in development mode since it is incompatible with CSS hot reloading. However, you can still enforce extraction in all cases by explicitly setting the value to true.

Instead of a true, you can also pass an object of options for the mini-css-extract-plugin if you want to further configure what this plugin does exactly.

链接: https://cli.vuejs.org/config/#css-extract

第二种方法就是在编译的时候更换模式, 在脚手架中进行设置

 

原博客: https://blog.csdn.net/weixin_45615791/article/details/104294458

posted @ 2020-04-21 08:29  943987243  阅读(6053)  评论(0编辑  收藏  举报