o***@163.com
o***@163.com
  • 发布:2023-12-26 15:47
  • 更新:2023-12-28 11:01
  • 阅读:269

uniapp vue-cli 公用的less变量文件 打包 命令npm run build:h5 报变量不存在的错

分类:uni-app

error in ./src/pagesB/myWallet/myWallet.vue?vue&type=style&index=1&id=44118580&scoped=true&lang=less&

Syntax Error:

.wallet_r>div {
.center();
^
.center is undefined
in /Users/wangxian/Documents/HBuilderProjects/my-h5/src/static/css/myWallet/myWallet.less (line 62, column 4)

@ ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/h5-vue-style-loader??ref--11-oneOf-1-0!./node_modules/css-loader/dist/cjs.js??ref--11-oneOf-1-1!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader??ref--11-oneOf-1-2!./node_modules/postcss-loader/src??ref--11-oneOf-1-3!./node_modules/postcss-loader/src??ref--11-oneOf-1-4!./node_modules/less-loader/dist/cjs.js??ref--11-oneOf-1-5!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader??ref--11-oneOf-1-6!./node_modules/style-resources-loader/lib??ref--11-oneOf-1-7!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib??vue-loader-options!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-scoped-loader!./src/pagesB/myWallet/myWallet.vue?vue&type=style&index=1&id=44118580&scoped=true&lang=less& 4:14-968
@ ./src/pagesB/myWallet/myWallet.vue?vue&type=style&index=1&id=44118580&scoped=true&lang=less&
@ ./src/pagesB/myWallet/myWallet.vue
@ ./src/pages.json
@ ./src/main.js
@ multi ./src/main.js

2023-12-26 15:47 负责人:无 分享
已邀请:
o***@163.com

o***@163.com (作者) - 世间无对错

补充:整个less变量文件都未被引入 。

且 使用HbuilderX工具运行打包可以正常使用。

const path = require('path')

module.exports = {
css: {
loaderOptions: {
less: {
javascriptEnabled: true,
modifyVars: {
'hack': true;@import "${path.resolve(__dirname, './').replace(/\\/g, '\\\\')}/xxxxxx.less";
}
}
}
}
}

o***@163.com

o***@163.com (作者) - 世间无对错

const path = require('path')  

module.exports = {  
    css: {  
        loaderOptions: {  
            less: {  
                javascriptEnabled: true,  
                modifyVars: {  
                    'hack': `true;@import "${path.resolve(__dirname, './').replace(/\\/g, '\\\\')}/laike.less";`  
                }  
            }  
        }  
    }  
}    
  • o***@163.com (作者)

    vue-cli 模式下没有用

    2023-12-26 15:49

YUANRJ

YUANRJ

请提供下测试工程

o***@163.com

o***@163.com (作者) - 世间无对错

感谢。从vue.config.js引入不行 换成每个less文件引入一次 就能使用 npm run build:h5 打包了

要回复问题请先登录注册