Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有关vue cli 3中在.vue中想导入想要的.styl样式 问题 #2631

Closed
mhxy13867806343 opened this issue Sep 27, 2018 · 2 comments
Closed

Comments

@mhxy13867806343
Copy link

Version
3.0.3

Node and OS info
node: v10.10.0 npm: 6.4.1 win

错误如下:

Module build failed (from ./node_modules/stylus-loader/index.js):
Error: E:\vuedemo\flaskVueLofter\src\views\login\index.vue:31:8
27| font-size $font-size-large-mx
28| }
29| }
30| }
31| }
--------------^
32| }
33| </style>

failed to locate @import file @$/base/style/variable.styl

at CachedPathEvaluator.visitImport (E:\vuedemo\flaskVueLofter\node_modules\stylus-loader\lib\evaluator.js:157:21)
at CachedPathEvaluator.Visitor.visit (E:\vuedemo\flaskVueLofter\node_modules\stylus\lib\visitor\index.js:28:40)
at CachedPathEvaluator.Evaluator.visit (E:\vuedemo\flaskVueLofter\node_modules\stylus\lib\visitor\evaluator.js:160:18)
at CachedPathEvaluator.Evaluator.visitRoot (E:\vuedemo\flaskVueLofter\node_modules\stylus\lib\visitor\evaluator.js:707:27)
at CachedPathEvaluator.Visitor.visit (E:\vuedemo\flaskVueLofter\node_modules\stylus\lib\visitor\index.js:28:40)
at CachedPathEvaluator.Evaluator.visit (E:\vuedemo\flaskVueLofter\node_modules\stylus\lib\visitor\evaluator.js:160:18)
at CachedPathEvaluator.Evaluator.evaluate (E:\vuedemo\flaskVueLofter\node_modules\stylus\lib\visitor\evaluator.js:247:15)
at Renderer.render (E:\vuedemo\flaskVueLofter\node_modules\stylus\lib\renderer.js:86:26)
at E:\vuedemo\flaskVueLofter\node_modules\stylus-loader\index.js:167:12
at tryCatchReject (E:\vuedemo\flaskVueLofter\node_modules\when\lib\makePromise.js:840:30)
at runContinuation1 (E:\vuedemo\flaskVueLofter\node_modules\when\lib\makePromise.js:799:4)
at Fulfilled.when (E:\vuedemo\flaskVueLofter\node_modules\when\lib\makePromise.js:590:4)
at Pending.run (E:\vuedemo\flaskVueLofter\node_modules\when\lib\makePromise.js:481:13)
at Scheduler._drain (E:\vuedemo\flaskVueLofter\node_modules\when\lib\Scheduler.js:62:19)
at Scheduler.drain (E:\vuedemo\flaskVueLofter\node_modules\when\lib\Scheduler.js:27:9)
at _combinedTickCallback (internal/process/next_tick.js:131:7)

@ ./node_modules/vue-style-loader??ref--11-oneOf-1-0!./node_modules/css-loader??ref--11-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node
_modules/postcss-loader/lib??ref--11-oneOf-1-2!./node_modules/stylus-loader??ref--11-oneOf-1-3!./node_modules/style-resources-loader/lib??ref--11-oneOf-1-4!./node
_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/login/index.vue?vue&type=style&index=0&id=37dfd6fc&lang=
stylus&scoped=true& 4:14-556 14:3-18:5 15:22-564
@ ./src/views/login/index.vue?vue&type=style&index=0&id=37dfd6fc&lang=stylus&scoped=true&
@ ./src/views/login/index.vue
@ ./src/router.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://192.168.1.3:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

出现问题
@import"@$/base/style/variable.styl" 或者@import'~css/index.styl'
使用以上2种方式进行导入,均出现上面的错误
使用在vue.config.js中[我是根据文档方式]如下
module.exports = {
chainWebpack: config => {
const types = ['vue-modules', 'vue', 'normal-modules', 'normal','stylus']
types.forEach(type => addStyleResource(config.module.rule('stylus').oneOf(type)))
},
}

function addStyleResource (rule) {
rule.use('style-resource')
.loader('style-resources-loader')
.options({
patterns: [
path.resolve(__dirname, './src/base/style/variable.styl'),
],
})
}
来导入文件的是可以的,但是会出现,当我修改.styl文件中的页面时,页面未改变,需要重启服务,页面才会改变

我需要的是

<style lang="stylus" scpoe> @import'~css/a.styl' </style>

这样的方式进行导入,如果样式修改后,不用重启就能够看到,请问下,哪些朋友遇到过,并解决了这个问题

@vue-bot
Copy link

vue-bot commented Sep 27, 2018

Hello, your issue has been closed because it does not conform to our issue requirements. In order to ensure every issue provides the necessary information for us to investigate, we require the use of the Issue Helper when creating new issues. Thank you!


你好,你的 issue 不符合我们所要求的格式,因此已被自动关闭。为了确保每个 issue 都提供必需的相关信息,请务必使用我们的 Issue 向导 来创建新 issue,谢谢!

@yoyo837
Copy link

yoyo837 commented Apr 15, 2022

Your means is addStyleResource support HMR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants