MENU

webpack踩坑记录

February 5, 2020 • Read: 84 • 简介

vue-cli-service-build报错No module factory available for dependency type: CssDependency
在vue.config.js里配置

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

ts中axios返回not exist on type 'AxiosResponse'
Property 'content' does not exist on type 'AxiosResponse<any>'.Vetur(2339)
新增axios.d.ts文件

import * as axios from 'axios'

declare module 'axios' {
  interface AxiosInstance {
    (config: AxiosRequestConfig): Promise<any>
  }
}

ts中提示Parameter 'xxx' implicitly has an 'any' type.
文件tsconfig.json中把"strict": true,改为false


打包后静态资源路径不对
vue.config.js文件

module.exports = {
  publicPath: '',
}

打包后的样式与打包前的样式不对应:
webpack是按顺序打包css文件,把自定义的全局样式放在main第一行即可