我有一个 nuxt 3 应用程序,我想通过 .less 文件设置全局样式。
nuxt.config.ts
css: [
"@/assets/less/main.less"
],
如果我跑步
yarn run dev
一切正常,但是当我跑步时
yarn run build
(nuxt 构建)和 yarn run preview
(nuxt 预览).less 文件不存在。由于某种原因,构建不包含 .less 文件中的任何样式。
我尝试添加
less-loader
包(尽管我知道 nuxt3 中不需要它)。
我想问题在于 NODE_ENV production / develop
的差异,但我不确定如何或应该配置什么以使构建涉及 .less 文件。
这是我的
package.json
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"analyze": "nuxt analyze",
"cleanup": "nuxt cleanup"
},
"devDependencies": {
"@nuxtjs/eslint-config": "^11.0.0",
"@nuxtjs/eslint-config-typescript": "^11.0.0",
"@popperjs/core": "^2.11.6",
"bootstrap": "^5.2.2",
"dayjs": "^1.11.5",
"eslint": "^8.24.0",
"less": "^4.1.3",
"less-loader": "^11.1.0",
"line-clamp": "^1.0.0",
"nuxt": "3.0.0-rc.10",
"vue": "^3.2.40"
},
"dependencies": {
"@microsoft/signalr": "^7.0.0",
"bootstrap-vue-3": "0.4.13",
"mitt": "^3.0.0",
"vue-disqus": "^5.1.0",
"vue-gtag": "^2.0.1",
"vue-next-masonry": "1.1.3",
"vue-tweet": "^2.0.2"
}
}
尝试在依赖项中安装 less,而不是在 devDependency 中安装