Component style not being applied in production -Vue - css

I have a component IndexHero.vue that has a scoped style applied to it
<template>
<v-container fluid>
<div id="tsparticles" class="particles"></div>
<v-container
fill-height
class='mt-n16 fullheight pa-0'
>
<v-row justify="center">
<v-col cols='12' align='center'>
<h1 class=" mt-n16 display-1 font-weight-black">
HEADING
</h1>
</v-col>
</v-row>
</v-container>
</v-container>
</template>
<style scoped>
.particles {
height: 100px;
width: 100px;
border: 2px dashed #f00;
}
</style>
This works fine while I'm in development npm run dev but when I generate the static build npm run generate the class name is there on the element but the class just isn't there.
I've seen other posts like this use ::v-deep particles and * >>> particles but that has not been successful for me. I've also tried removing scoped but that didn't work either. Can anyone point me in the direction of getting the style applied? Also I'm using Nuxt v2.14.4
Update:
How it shows up in the DOM tree. The canvas element is inserted by a JS library tsparticles just btw.
nuxt.config.js
import colors from 'vuetify/es5/util/colors'
import {fireDb} from './plugins/firebase';
export default {
mode: 'universal',
target: 'static',
components: true,
render: {
fallback: false
},
//If you're debugging firebase cloud messaging notifications, comment off lines 10 and 11
//Those two lines exposes the Nuxt dev server on an IP so multiple devices can connect
//And debug across platforms/screen sizes
server: {
port: 8000, // default: 3000
host: '0.0.0.0', // default: localhost
},
/*
** Headers of the page
*/
head: {
title: 'COVID-19 in Trinidad and Tobago',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: "Information on this website is not real please do not use or take into consideration.This is the developer site for CoronavirusInfoTT." },
{ hid: 'theme-color', name: 'theme-color', content: '#121212'},
//Apple Related Tags
{ hid: 'apple-mobile-web-app-title', name: 'apple-mobile-web-app-title', content: 'CoronavirusInfoTT - Developer'},
{ hid: 'apple-mobile-web-app-status-bar-style', name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent'},
//Facebook Open Graph Tags
{ hid: 'og:url', property: 'og:url', content: 'https://developer.coronavirustt.info/'},
{ hid: 'og:title', property: 'og:title', content: 'CoronavirusInfoTT - Developer'},
{ hid: 'og:description', property: 'og:description', content: "Information on this website is not real please do not use or take into consideration.This is the developer site for CoronavirusInfoTT."},
{ hid: 'og:site_name', property: 'og:site_name', content: 'developer.coronavirustt.info/'},
{ hid: 'og:image', property: 'og:image', content: 'https://developer.coronavirustt.info/tagimageversiontwo.png'},
{ hid: 'og:image:type', property: 'og:image:type', content: 'image/png'},
{ hid: 'og:image:height', property: 'og:image:height', content: '800'},
{ hid: 'og:image:width', property: 'og:image:width', content: '800'},
{ hid: 'og:image:alt', property: 'og:image:alt', content: 'A preview of the landing page'},
{ hid: 'og:type', property: 'og:type', content: 'website'},
//Twitter tags
{ hid: 'twitter:card', name: 'twitter:type', content: 'summary_large_image'},
{ hid: 'twitter:url', name: 'twitter:url', content: 'https://developer.coronavirustt.info/'},
{ hid: 'twitter:title', name: 'twitter:title', content: 'CoronavirusInfoTT- Developer'},
{ hid: 'twitter:description', name: 'twitter:description', content: "Information on this website is not real please do not use or take into consideration.This is the developer site for CoronavirusInfoTT."},
{ hid: 'twitter:image', name: 'twitter:image', content: 'https://developer.coronavirustt.info/tagimageversiontwo.png'},
{ hid: 'twitter:image:alt', name: 'twitter:image:alt', content: 'A preview of the landing page for the website'},
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
//{ rel: 'preload', as:'style', href: '../node_modules/#mdi/font/css/materialdesignicons.min.css' },
]
},
/*
** Customize the progress-bar color
*/
//loading: '#/components/WanderingCubes',
/*
** Global CSS
*/
css: [
'typeface-roboto/index.css',
'#mdi/font/css/materialdesignicons.min.css',
'#/assets/main.css',
],
/*
** Plugins to load before mounting the App
*/
plugins: [
'#/plugins/firebase.js',
],
/*
** Nuxt.js dev-modules
*/
buildModules: [
'#nuxtjs/vuetify',
'#nuxt/components',
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://axios.nuxtjs.org/usage
'#nuxtjs/pwa',
'#nuxtjs/sitemap',
],
pwa: {
icon:{
sizes: [64, 120, 144, 152, 192, 384,512],
},
manifest:{
name: 'CoronavirusInfoTT',
short_name: 'COVID-19TT',
description: "Statistics and information about the COVID-19 virus in Trinidad and Tobago. See visualizations about the virus' activity regarding the number of cases, deaths and recoveries as well as reopening phases. It also acts as a hub for updates from the relevant authorities",
lang: 'en',
background_color: '#121212',
}
},
sitemap: {
hostname: 'https://coronavirustt.info',
gzip: true,
exclude: [
'/adminlogin',
'/admindashboard',
],
},
/*
** vuetify module configuration
** https://github.com/nuxt-community/vuetify-module
*/
vuetify: {
customVariables: ['~/assets/variables.scss'],
defaultAssets:false,
//treeShake: true,
theme: {
dark: true,
themes: {
dark: {
primary: colors.blue.darken2,
accent: colors.grey.darken3,
secondary: colors.amber.darken3,
info: colors.teal.lighten1,
warning: colors.amber.base,
error: colors.deepOrange.accent4,
success: colors.green.accent3
}
}
}
},
/*
** Build configuration
*/
build: {
/*
** You can extend webpack config here
extend (config, {isClient}) {
if (isClient){
config.optimization.splitChunks.maxSize = 200500;
}
}
*/
},
generate:{
//fallback: false,
async routes(){
const qs = await fireDb.collection('covid19tt/initiatives/initiatives').get();
let d = qs.docs.map(function(x){
let title = x.data().title;
if(title !== undefined){
title = title.toLowerCase().replace("'",'').replace(/ /g,'-');
let date = String( x.data().dateAdded);
let data = x.data();
data['dateAdded'] = date;
data['pageURL']= `https://coronavirustt.info/initiative/${data.urlTitle}/`;
return {
route: `/initiative/${x.data().urlTitle}/`,
payload: data,
};
}else{
return null;
}
});
d = d.filter( f=>{
if( f !== null) return f;}
)
return d;
}
},
}
Update:

I've worked with TsParticles before and it can be problematic sometimes.
You can check my working example on github of TsParticles on Vue.js / Nuxt.js.
<div id="tsparticles" class="particles"></div>
Based on my own previous strugles, I suggest you to rename your id to something different from tsparticles, as the names can collide on javascript (it happened to me).

Related

Wpgraphql queries under fetching queries from wordpress

I have this issue were I'm trying to request images I've uploaded on my WordPress instance with graphql from Gatsby but I only get the most recent item I uploaded on wordpress.
When i query using the Graphiql IDE on WordPress I the desired results. See this image ➡️
Image of the query and response in get from Graphiql IDE on wordpress
Below is the query and response in get from Graphiql IDE on wordpress
// Graphiql IDE query
{
mediaItems {
edges {
node {
databaseId
}
}
}
}
// The response
{
"data": {
"mediaItems": {
"edges": [
{
"node": {
"databaseId": 30
}
},
{
"node": {
"databaseId": 28
}
},
{
"node": {
"databaseId": 26
}
},
{
"node": {
"databaseId": 20
}
}
]
}
},
"extensions": {
"debug": []
}
}
but when I query from the http://localhost:8000/___graphql endpoint on my local development as I said earlier I only get the most recent upload.
Image of local development query and response
the code is below
// The query to http://localhost:8000/___graphql endpoint
{
wpMediaItem {
altText
localFile {
childImageSharp {
gatsbyImageData(placeholder: TRACED_SVG, width: 100)
id
}
}
}
}
// The response
{
"data": {
"wpMediaItem": {
"altText": "background lines",
"localFile": {
"childImageSharp": null
}
}
},
"extensions": {}
}
The ednpoints I can query
the enpoints img 1
the enpoints img 2
Below is my gatsby-config.js file
const path = require("path");
// Get paths of Gatsby's required rules, which as of writing is located at:
// https://github.com/gatsbyjs/gatsby/tree/fbfe3f63dec23d279a27b54b4057dd611dce74bb/packages/
// gatsby/src/utils/eslint-rules
const gatsbyRequiredRules = path.join(
process.cwd(),
"node_modules",
"gatsby",
"dist",
"utils",
"eslint-rules"
);
module.exports = {
siteMetadata: {
title: `########`,
description: `################`,
author: `###################`,
siteUrl: `###############`,
},
plugins: [
`gatsby-plugin-image`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
// This will impact how browsers show your PWA/website
// https://css-tricks.com/meta-theme-color-and-trickery/
// theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
},
},
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-wordpress`,
options: {
url: `http://34.133.115.37/graphql`,
},
},
{
resolve: `gatsby-plugin-google-fonts`,
options: {
fonts: [`Poppins`],
display: `swap`,
},
},
{
resolve: `gatsby-plugin-styled-components`,
options: {
// Add any options here
},
},
{
resolve: "gatsby-plugin-eslint",
options: {
// Gatsby required rules directory
rulePaths: [gatsbyRequiredRules],
// Default settings that may be ommitted or customized
stages: ["develop"],
extensions: ["js", "jsx", "ts", "tsx"],
exclude: ["node_modules", "bower_components", ".cache", "public"],
// Any additional eslint-webpack-plugin options below
// ...
},
},
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,
],
}
I don't know but probably my query is request is wrong, I have tried every can some help
wpMediaItem is not the same node as wpMediaItems (spot the trailing S). The first one is querying a single node, which by default would be sorted by upload date, while wpMediaItems fetch for all images, an array of images (edges in this case), that's why you can get edges in one query and an isolated node in the other, directly accessing for that node data (altText, etc.).
Take a deeper look at the GraphiQL playground (http://localhost:8000/___graphql) to get the correct node, but it should be there.

Vercel Deployment of Remix.js & Tailwind CSS (with NextUI) App: No CSS styling in Deployment

I'm pretty lost. Trying to deploy my Remix Tailwind App which is working perfectly in Dev Environment.
Dev Environment working fine
As soon as I deploy, almost anything is gone basically. See here:
Vercel Env not working
Here's my tailwind config file:
content: ["./app/**/*.{ts,tsx,jsx,js}"],
module: {
rules: [
{
test: /\.css$/i,
use: ["style-loader", "css-loader"]
}
]
},
safelist: [{ pattern: /.*/ }],
theme: {
screens: {
xxs: "350px",
custom3: "420px",
xs: "480px",
custom2: "580px",
sm: "676px",
md: "768px",
custom: "910px",
lg: "1050px", // laptop: Default screen size
xl: "1280px", //desktop
"2xl": "1526px",
"3xl": "1696px"
},
extend: {
colors: {
textLgColor: "var(--text-large-color)",
textSmColor: "var(--text-small-color)",
subText: "var(--sub-text-color)",
navBar: {
linkActive: "var(--nav-link-active)",
linkActiveStripe: "var(--nav-link-active-stripe)"
},
mobileNav: {
text: "var(--mobile-text)",
textHover: "var(--mobile-hover-text)",
border: "var(--mobile-border)"
},
aboutMe: {
smIconBg: "var(--sm-icon-bg)",
aboutMeText: "var(--aboutme-text)",
alissa: "var(--alissa)"
},
projects: {
text: "var(--project-text-color)",
subText: "var(--project-sub-text)",
arrow: "var(--project-arrow)",
recentBg: "var(--recent-project-bg)",
recentHover: "var(--recent-project-bg-hover)",
recentShadow: "var(--recent-project-shadow)"
},
contact: {
label: "var(--label-text)",
send: "var(--send-btn)",
sendHover: "var(--send-btn-hover)"
},
blog: {
lgText: "var(--blog-lg-text)",
border: "var(--blog-input-border)",
tagBg: "var(--tag-btn-bg)"
},
post: {
bodyText: "var(--text-body)",
bodyTextLg: "var(--text-body-lg)",
icon: "var(--icon)",
iconHover: "var(--icon-hover)",
hyperlink: "var(--hyperlink)",
hyperlinkHover: "var(--hyperlink-hover)",
quote: "var(--quote)",
quoteAuthor: "var(--quote-author)"
}
}
}
},
plugins: [require("#tailwindcss/line-clamp")]
};
As this point I'm so frustrated, idgaf about my codebase anymore so here you go, I just made the repo public: https://github.com/flo-s99/Devato/settings
Any help appreciated

Enable hover only on top/bottom/left/right

I'm trying to create a variant in Tailwind file configuration.
What I would like to have is something like hover:border-l-4 hover:border-green-400, so a class that enables a border on the left (or only on top / bottom / right).
So I create this inside tailwind.config.js:
module.exports = {
purge: {
enabled: process.env.NODE_ENV === 'production',
content: ['./src/**/*.html', './src/**/*.{js,ts,jsx,tsx}'],
},
darkMode: false,
theme: {
extend: {
colors: {
...
},
},
borderLeft: (theme) => ({}),
...
},
variants: {
extend: {
borderLeft: ['hover', 'focus']
},
},
plugins: [],
}
It doesn't work. I get TypeError: variantsValue is not iterable.
I didn't find anything useful in the documentation page.
Checkout docs on tailwind.
variants: {
extend: {
borderWidth: ['hover'],
}
}
From here, hover:border-l-4 hover:border-green-400 will work.

Nuxt basic auth does not work on Firebase

I am working on a Nuxt project which is deployed on firebase. I have basic auth configuration set up using nuxt-basic-auth-module.
It works locally, but on firebase does not work which I do not why. Am I doing something wrong? Additional settings required? Please give me advices. Thank you very much.
nuxt.config.js
import colors from 'vuetify/es5/util/colors'
require('dotenv').config()
export default {
mode: 'universal',
head: {
titleTemplate: '%s - ' + process.env.npm_package_name,
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
loading: { color: '#fff' },
buildModules: [
'#nuxtjs/vuetify',
'#nuxtjs/dotenv'
],
modules: [
'#nuxtjs/axios',
'#nuxtjs/proxy',
'nuxt-basic-auth-module'
],
build: {
extend (config, ctx) {
}
},
server: {
port: 4000, // default: 3000
host: '0.0.0.0' // default: localhost
},
env: {
baseUrl: process.env.BASE_URL
},
basic: {
name: 'basicauthusername',
pass: 'basicauthpasswrd1234'
}
}
As mentioned on documentation, enabled comes with false value by default
basic: {
name: 'basicauthusername',
pass: 'basicauthpasswrd1234'
enabled: true // Add this property
}

How to get CSS IntelliSense to work on a Nuxt project?

I'm working on a Nuxt.js Project, I created a Docker image as well to handle everything; I'm also trying to include MDBVue as a CSS library, after reading I understand that in order to use this I have to include it as a plugin and reference it on my nuxt.config.js file;
This is how my file looks:
module.exports = {
/*
** Headers of the page
*/
head: {
title: 'skfe',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Nuxt.js project' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
/*
** Customize the progress bar color
*/
loading: { color: '#3B8070' },
css: [
{ src: "bootstrap-css-only/css/bootstrap.min.css" },
{ src: "mdbvue/build/css/mdb.css" }
],
/*
** Build configuration
*/
build: {
/*
** Run ESLint on save
*/
extend (config, { isDev, isClient }) {
if (isDev && isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
}
}
}
Now the CSS classes work, but I'm not able to get any autocompletion from VSCode, I have to type in the full class name; is this normal behavior or is there a way to get IntelliSense to work on my Vue files?
This is the normal behaviour:
https://github.com/Microsoft/vscode/issues/27635
Try the plugin:
IntelliSense for CSS class names in HTML
or
HTML CSS Support
Source: https://code.visualstudio.com/docs/languages/css
And of course Vetur a must-have plugin for vue development in vscode.

Resources