我试图在nuxt中加载一个手写笔文件。
首先,我使用npm i -D stylus stylus-loader安装了手写笔包。
然后我在app.styl文件夹中创建了一个名为assets/style的文件:
@require '~vuetify/src/stylus/settings/_colors'
$theme := {
primary: $blue.darken-2
accent: $blue.accent-2
secondary: $grey.lighten-1
info: $blue.lighten-1
warning: $amber.darken-2
error: $red.accent-4
success: $green.lighten-2
}
// Import Vuetify styling
@require '~vuetify/src/stylus/main'
.page
@extend .fade-transition然后我将其添加到nuxt.config.js中的css数组中:
/*
** Global CSS
*/
css: [{ src: '~assets/style/app.styl', lang: 'styl'}],但是,nuxt.js在构建中抛出了一个错误:
× error friendly-errors » Failed to compile with 1 errors
> log friendly-errors » This dependency was not found:
> log friendly-errors » * ..\assets\style\app.styl in ./.nuxt/App.js
> log friendly-errors » To install it, you can run: npm install --save ..\assets\style\app.styl在我的package.json中,nuxt的版本为^2.3.1,手写笔的版本为^0.54.5,手写笔加载程序的版本为^3.0.2。
到package.json和nuxt.config.js的完整链接
你能发现我使用这些信息的设置有什么问题吗?
发布于 2018-11-22 00:34:55
对于Nuxt js版本2来说,nuxt资产文件夹路径应该是这样的。
/*
** Global CSS
*/
css: [{ src: '~/assets/style/app.styl', lang: 'styl'}]我希望它能解决你的问题
发布于 2020-03-29 13:08:35
这条线对我有用。在nuxt.config.js中
css:'~assets/app.styl‘
发布于 2020-11-12 10:24:20
从问题讨论nuxt问题到webpack手写笔选项和nuxt的最新解决方案(2.14.7),
扩展webpack配置映射所有加载器,
build: {
extend (config, { isDev, isClient }) {
[].concat(...config.module.rules.find(e => e.test.toString().match(/\.styl/)).oneOf.map(e => e.use.filter(e => e.loader == 'stylus-loader'))).forEach(stylus => {
Object.assign(stylus.options, {
//preferPathResolver: 'webpack',
sourceMap: true,
stylusOptions: {
//use: ['nib'],
include: ['~assets/styles'], //include all styl files from folder
import: [
'~assets/style/main.styl', //your main styl file
],
},
})
//console.log(stylus)
})
},这将导入文件并包括手写笔文件夹。
https://stackoverflow.com/questions/53421331
复制相似问题