vue.config.js 似乎没有加载

Posted

技术标签:

【中文标题】vue.config.js 似乎没有加载【英文标题】:vue.config.js does not seem to load 【发布时间】:2021-09-20 14:51:54 【问题描述】:

在:

https://codesandbox.io/s/dazzling-jepsen-r7283?file=/vue.config.js

基于:

https://***.com/a/68308416/1079483

vue.config.js

const path = require("path");
module.exports = 
  configureWebpack: 
    resolve: 
      alias: 
        "modal-styles": path.resolve(__dirname, "./src/styles/modal-style.css")
      
    
  ,
  css: 
    loaderOptions: 
      less: 
        modifyVars: ,
        javascriptEnabled: true
      
    
  
;

不是由 vue-cli 加载的。这个想法是复制:

https://codesandbox.io/s/cs-vue-cli-3-vj2rl?file=/vue.config.js

当到达EditCategory.vuestyles标签时:

<style scoped>
@import 'modal-styles';
</style>

别名无法读取:

TypeError
Path must be a string. Received null
r
https://codesandbox.io/static/js/common-sandbox.7be24d846.chunk.js:1:246770
Object.isAbsolute
https://codesandbox.io/static/js/common-sandbox.7be24d846.chunk.js:1:247916
(anonymous function)
https://codesandbox.io/static/js/vendors~postcss-compiler~vue-style-compiler.f9e51cefa.chunk.js:1:1069
(anonymous function)
https://codesandbox.io/static/js/vendors~postcss-compiler~vue-style-compiler.f9e51cefa.chunk.js:1:1060
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error.
This error overlay is powered by `react-error-overlay` used in `create-react-app`.

【问题讨论】:

【参考方案1】:

style中的路径错误:

<style>
  @import '/src/styles/modal-style.css';
</style>

【讨论】:

以上是关于vue.config.js 似乎没有加载的主要内容,如果未能解决你的问题,请参考以下文章

vuecli3打包部署 非根目录下 配置vue.config.js publicPath

vue-cli创建项目没有集成webpack相关配置的如何解决

如何在 vue.config.js 中为 node_modules 添加 sass 加载器

vue.config.js中的webpack配置,优化及多页面应用开发

vue.config.js 配置

Vue CLI 3 vue.config.js 编译“未知单词”错误