I created an app in nuxt 3 (rc. 4). When you start the application, you will notice that the styles of the elements are duplicated. The problem only occurs when yarn dev is used (after generating an application with yarn generate problem disappears):
devtools image
As already mentioned, I use the nuxt version rc 4. In the previous version I didn’t notice this problem after.
package.json
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview"
},
"devDependencies": {
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/pro-light-svg-icons": "^6.1.1",
"@fortawesome/pro-regular-svg-icons": "^6.1.1",
"@fortawesome/vue-fontawesome": "^3.0.1",
"nuxt": "3.0.0-rc.4",
"sass": "^1.52.2",
"sass-loader": "^13.0.0"
}
}
nuxt.config.ts
import { defineNuxtConfig } from 'nuxt'
import path from 'path';
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
srcDir: path.join(__dirname, 'src'),
alias: {
'@': path.join(__dirname, 'src')
},
vite: {
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "@/assets/css/import.scss";'
}
}
}
},
typescript: {
shim: false,
strict: true,
},
css: [
'@/assets/css/global.scss',
'@fortawesome/fontawesome-svg-core/styles.css',
],
plugins: [
'@/plugins/fontawesome.ts'
],
})
assets/global.scss
/*
1. Fonts
2. CSS reset
3. Global styles
*/
// #############################################
// 1. Fonts
@import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,[email protected],300;8..144,400;8..144,500;8..144,600;8..144,700&display=swap');
// 2. CSS reset
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
// 3. Global styles
*, *::before, *::after {
font-family: 'Roboto Flex', sans-serif;
}
components/drawer/index.vue
<template>
<div class="drawer">
drawer
</div>
</template>
<style lang="scss">
@import './CDrawer.scss';
</style>
components/drawer/CDrawer.scss
.drawer {
background: black;
}
I want to solve this problem because it makes work on the project more difficult. I can’t find a solution to the problem and I think the configuration is fine. Is he wrong? Thank you so much for your help