Answer the question
In order to leave comments, you need to log in
Vue css modules?
What I read on the topic
https://cli.vuejs.org/guide/css.html#css-modules
https://vue-loader.vuejs.org/guide/css-modules.htm...
https://github .com/zhouwenbin/css-modules-vue-demo...
https://habr.com/ru/company/constanta/blog/428800/
https://habr.com/ru/post/335244/
https:/ /github.com/css-modules/css-modules/pull/65
Tried to import styles outside the style block component as in one of the git examples above.
import stylesss from '[email protected]/assets/public/scss/public.scss';
ERROR in ./src/components/public/layouts/basic.vue?vue&type=script&lang=js& (./node_modules/source-map-
loader!./node_modules/vue-loader/lib??vue-loader-options!./src/components/public/layouts/basic.vue?vue&type=script&lang=js&)
Module not found: Error: Can't resolve 'style' in '/var/www/test/src/components/public/layouts'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
You need to specify 'style-loader' instead of 'style',
see https://webpack.js.org/migrate/3/#automatic-loader-module-name-extension-removed
<style lang="scss" module type="text/scss">
@import '[email protected]/assets/public/scss/public.scss';
// all other imports
</style>
app: "src-components-public-layouts-basic__app--1Df-Y"
{
test: /\.css$/,
use: [
'vue-style-loader',
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[path][name]__[local]--[hash:base64:5]',
sourceMap: true,
},
},
],
},
{
test: /\.scss$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[path][name]__[local]--[hash:base64:5]',
sourceMap: true,
},
},
{
loader: 'sass-loader',
},
],
},
<style lang="scss" module type="text/scss">
@import '[email protected]/fontawesome-free/css/all.css';
@import '[email protected]/assets/common/scss/common.scss';
</style>
@import '~bootstrap/scss/bootstrap';
@import 'variables';
@import 'globals';
@import 'helpers';
@import 'override';
...
.test3{
display: block;
}
mounted () {
console.log(this.$style);
console.log(this.$style.test3);
},
test3: "src-App__test3333333333333--2qUvj"
console.log(this.$style['col-md-12']);
Modules as an alternative for simulated scoped CSS
Answer the question
In order to leave comments, you need to log in
1 - all mixins are scoped by default, regardless of whether they are specified as scoped or not
2 - import of global styles is now only via import()
import stylesss from '@/assets/common/scss/common.scss';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question