when built done, then css in tailwind is not display
In my package.json. I dont know build with tailwind look like, i just use the default.
{
"name": "portiflo",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"development": "vue-cli-service serve --mode development",
"build": "vue-cli-service build"
},
"dependencies": {
"#fortawesome/fontawesome-svg-core": "^1.2.36",
"#fortawesome/free-solid-svg-icons": "^5.15.4",
"#fortawesome/vue-fontawesome": "^3.0.0-5",
"core-js": "^3.6.5",
"vue": "^3.0.0",
"vue-pdf": "^4.3.0",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-router": "~4.5.0",
"#vue/cli-plugin-vuex": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/compiler-sfc": "^3.0.0",
"autoprefixer": "^9.8.6",
"postcss": "^7.0.36",
"tailwindcss": "npm:#tailwindcss/postcss7-compat#^2.2.7"
}
And in my tailwind.config.js, i add some color, and default, i dont edit anymore.
module.exports = {
purge: [
'./src/**/*.html',
'./src/**/*.js',
],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
backgroundColor: theme => ({
...theme('colors'),
'yellow-background': '#FEF48E',
'red-headbar': '#90E39A',
'green-body': '#EDD9A3',
'post': '#FBE7C6'
})
},
variants: {
extend: {},
},
plugins: [],
}
I think you're missing to import tailwind css into you project. It may be App.vue or main.js file. You just add below line top of your script.
import from './tailwind.css'
and of course in tailwind.css file should have below code inserted.
/* ./tailwind.css */
#tailwind base;
#tailwind components;
#tailwind utilities;
Related
Embarrassingly, this problem has been holding me up for days, and I must, must get on with my task for work, so I'm reaching out for help.
When running Cypress, I get said error: process is not defined and it points to a JavaScript file in the client portion of my project (shown below). I understand process is a nodeJS property, but I can obviously call this on the FE of my application, and must, so I don't understand why Cypress is throwing an error here. Any help would be much appreciated. I'm running node v14.x.x.
vue.config.js
const { defineConfig } = require('#vue/cli-service')
// const { VueLoaderPlugin } = require('vue-loader')
module.exports = defineConfig({
css: {
loaderOptions: {
sass: {
additionalData: '#import src/styles/base/entry.scss',
},
},
},
lintOnSave: false,
publicPath: '/',
transpileDependencies: true,
})
Package.json
{
"name": "test2",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"test:e2e": "vue-cli-service test:e2e",
"lint": "vue-cli-service lint"
},
"dependencies": {
"#sentry/apm": "^5.27.1",
"#sentry/browser": "^7.28.1",
"#sentry/integrations": "^7.28.1",
"auth0-js": "^9.20.0",
"axios": "^1.2.2",
"axios-retry": "^3.3.1",
"big.js": "^6.2.1",
"core-js": "^3.8.3",
"css-loader": "^6.7.3",
"moment": "^2.29.4",
"moment-timezone": "^0.5.40",
"style-loader": "^3.3.1",
"toastr": "^2.1.4",
"uuid": "^9.0.0",
"vue": "^2.6.14",
"vue-router": "^3.5.2"
},
"devDependencies": {
"#babel/core": "^7.20.7",
"#babel/eslint-parser": "^7.19.1",
"#babel/preset-env": "^7.20.2",
"#cypress/webpack-preprocessor": "^5.16.1",
"#vue/cli-plugin-babel": "~5.0.0",
"#vue/cli-plugin-e2e-cypress": "~5.0.0",
"#vue/cli-plugin-eslint": "~5.0.0",
"#vue/cli-plugin-unit-jest": "~5.0.0",
"#vue/cli-service": "~5.0.0",
"#vue/test-utils": "^1.1.3",
"#vue/vue2-jest": "^27.0.0-alpha.2",
"babel-jest": "^27.0.6",
"babel-loader": "^8.0.2",
"cypress": "^9.7.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"jest": "^27.0.5",
"node-sass": "^4.14.0",
"sass-loader": "^12.6.0",
"ts-jest": "^27.0.4",
"vue-loader": "^15.0.1",
"vue-template-compiler": "^2.6.14",
"webpack": "^5.75.0"
}
}
Cypress webpack config
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const { VueLoaderPlugin } = require('vue-loader')
const webpackPreprocessor = require('#cypress/webpack-preprocessor')
/**
* #type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
const defaults = webpackPreprocessor.defaultOptions
// Add to existing rules
defaults.webpackOptions.module.rules.push(
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.sass$/i,
use: [
// creates 'style' nodes from JS strings
"vue-style-loader",
// Translates CSS into CommonJS
"css-loader",
// Compiles Sass to CSS
{
loader: "sass-loader",
options: {
additionalData: '#import src/styles/base/entry.scss',
// sass-loader >= 8
sassOptions: {
indentedSyntax: true,
},
},
},
],
}
)
// Add first plugin
defaults.webpackOptions.plugins = [ new VueLoaderPlugin() ]
console.log(defaults)
on('file:preprocessor', webpackPreprocessor(defaults))
}
sentryMixin.js
...
const environment = process.env.VUE_APP_ENV
^ this is where it points to the error
...
I use command in idea terminal
e.g.npm run electron:serve
My code environment:
Mac M1/macos Ventura13.0.1
node#14.21.2
npm#6.14.17
electron#12.2.3
The command stopped after Vue project compiled successful.
like this:
I try to run command rm -rf node_modules package-lock.json&&npm install
but cannot fix the situation.
Colleague's code environment:
win10
node#16.17.1
npm#8.19.2
electron#9.4.4
The normal situation in my colleague's computer:
This is my package.json
{
"name": "RetinaCare",
"version": "2.3.11",
"publishDate": "2022-03-07",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"electron:build": "vue-cli-service electron:build",
"electron:serve": "vue-cli-service electron:serve",
"postinstall": "electron-builder install-app-deps"
},
"main": "background.js",
"dependencies": {
"axios": "^0.21.1",
"chokidar": "^3.4.2",
"core-js": "^3.6.5",
"el-table-infinite-scroll": "^1.0.10",
"electron-builder": "^23.6.0",
"electron-updater": "^4.3.9",
"element-ui": "^2.13.2",
"html2canvas": "^1.0.0-rc.7",
"iconv-lite": "^0.6.3",
"js-md5": "^0.7.3",
"jspdf-html2canvas": "^1.4.9",
"print-js": "^1.2.0",
"qiao-is-online": "0.0.6",
"vue": "^2.6.11",
"vue-html-to-paper": "^1.3.1",
"vue-image-zoomer": "1.0.4",
"vue-print-nb": "^1.5.0",
"vue-qr": "^2.4.0",
"vue-router": "^3.2.0",
"vuex": "^3.4.0",
"xml2js": "^0.4.23"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-plugin-router": "~4.5.0",
"#vue/cli-plugin-vuex": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/eslint-config-standard": "^5.1.2",
"babel-eslint": "^10.1.0",
"electron": "^12.2.3",
"electron-devtools-installer": "^3.1.0",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.2.2",
"lint-staged": "^9.5.0",
"node-sass": "^4.12.0",
"sass-loader": "^8.0.2",
"vue-cli-plugin-electron-builder": "~2.0.0-rc.4",
"vue-template-compiler": "^2.6.11"
},
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.{js,jsx,vue}": [
"vue-cli-service lint",
"git add"
]
}
}
This is my vue.config.js
module.exports = {
pages: {
index: 'src/main.js',
login: 'src/login/main.js'
},
chainWebpack: config => {
config.resolve.symlinks(true)
},
devServer: {
hot: true,
hotOnly: true,
watchContentBase: false
},
configureWebpack: {
target: 'electron-renderer',
externals: ['fsevents']
},
pluginOptions: {
electronBuilder: {
extraResources: {
from: './public/dll',
to: './dll'
},
builderOptions: {
asar: false,
mac: {
target: {
target: 'default',
arch: [
'x64',
'arm64'
]
}
},
win: {
requestedExecutionLevel: 'requireAdministrator',
icon: './public/ljj_256.ico',
artifactName: '${productName}-Setup-${version}.${ext}',
target: [
{
target: 'nsis',
arch: [
'ia32'
]
}
]
},
productName: 'testProject',
nsis: {
include: './public/nsis/installer.nsh',
perMachine: false,
runAfterFinish: true,
oneClick: false,
allowElevation: true,
allowToChangeInstallationDirectory: true,
installerIcon: './public/ljj_256.ico',
uninstallerIcon: './public/ljj_256.ico',
installerHeaderIcon: './public/ljj_256.ico',
createDesktopShortcut: true,
createStartMenuShortcut: true,
shortcutName: 'electronProject',
deleteAppDataOnUninstall: true
},
publish: [
{
provider: 'generic',
url: 'https://www.electronProject_test.com/client'
}
]
}
}
}
}
This is project catalogue:
Because mac m1's framework is arm64,i changed electron version from ^9.2.0 to ^12.2.3, added electron-builder ^23.6.0 to package.json.
By the way i started sample project of vue-electron successful on the Mac.The question is so strange😭
The issue was resolved by delete yarn.lock in project. Beacuse of yarn.lock in my project, so vue-cli will look for yarn runtime environment in server. But i have not install yarn runtime environment on server. The code stop at hasProjectYarn(api.getCwd()). If you dont need yarn, Meanwhile yarn.lock file in your project ,you should delete the file!
I am new to graphql and I have been getting this error when trying to use .graphql file inside vue apollo. while using gql tag , it works fine , but while importing graphql file this error is showing up.
i have tried to use graphql loader but it doesnt seems to be working.
Failed to resolve loader: cache-loader
You may need to install it.
ERROR in ./src/client/pages/Clients.vue?vue&type=script&lang=js&
(./node_modules/babel-loader/lib/index.js??clonedRuleSet-
40.use[0]!./node_modules/#vue/cli-service/lib/config/vue-loader-v15-resolve-
compat/vue-loader.js??vue-loader-options!./src/client/pages/Clients.vue?
vue&type=script&lang=js&) 100:15-55
Module not found: Error: Can't resolve 'cache-loader' in '/home/noakash/temp/gym-
client'
# ./src/client/pages/Clients.vue?vue&type=script&lang=js& 1:0-246 1:262-265 1:267- 510 1:267-510
# ./src/client/pages/Clients.vue 2:0-59 3:0-54 3:0-54 9:2-8
# ./src/router/index.js 5:0-50 31:13-20
# ./src/main.js 3:0-30 18:2-8
webpack compiled with 1 error
my Clients.vue file look like this
apollo: {
clients() {
return {
query:require('../../graphql/clients.graphql'),
result({ loading }) {
this.loading = loading;
},
};
},
},
i am using vue-cli
my vue.config.js look like this
const { defineConfig } = require('#vue/cli-service')
module.exports = defineConfig({
configureWebpack:{
module:{
rules:[
{
test: /\.graphql$/,
use: 'graphql-tag/loader'
}
]
}
},
transpileDependencies: [
'vuetify'
],
})
my package.json
{
"name": "gym-client",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"apollo": "vue-cli-service apollo:dev --generate-schema",
"apollo:schema:generate": "vue-cli-service apollo:schema:generate",
"apollo:schema:publish": "vue-cli-service apollo:schema:publish",
"apollo:start": "vue-cli-service apollo:start"
},
"dependencies": {
"apollo-boost": "^0.4.9",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link": "^1.2.14",
"apollo-link-http": "^1.5.17",
"core-js": "^3.25.0",
"graphql": "^15.8.0",
"graphql-tag": "^2.12.6",
"jspdf": "^2.5.1",
"lowdb": "^1.0.0",
"mkdirp": "^0.5.1",
"moment": "^2.29.4",
"regenerator-runtime": "^0.13.9",
"shortid": "^2.2.8",
"vue": "^2.6.14",
"vue-apollo": "^3.1.0",
"vue-router": "^3.5.1",
"vuetify": "^2.6.0",
"vuex": "^3.6.2"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~5.0.0",
"#vue/cli-plugin-router": "~5.0.0",
"#vue/cli-plugin-vuex": "~5.0.0",
"#vue/cli-service": "~5.0.0",
"sass": "~1.32.0",
"sass-loader": "^10.0.0",
"vue-cli-plugin-apollo": "~0.22.2",
"vue-cli-plugin-vuetify": "~2.5.5",
"vue-template-compiler": "^2.6.14",
"vuetify-loader": "^1.7.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
I'm trying to create a MicroFrontend in Vue2 using module federation, like Pinia provides a singleton behaviour about stores that could be awesome for use in module federation, the problem is when I inject this an error is prompt ( I make previous test in a unique application and that works )
That is the error:
And the piece of code relative is:
My configuration is the next:
Child1: Who exposed it's components contains this vue.config.js
const { defineConfig } = require('#vue/cli-service')
const {ModuleFederationPlugin} = require("webpack").container;
const deps = require("./package.json");
module.exports = defineConfig({
transpileDependencies: true,
publicPath: 'auto',
configureWebpack: {
plugins: [
new ModuleFederationPlugin({
name: 'child1',
filename: 'remoteEntry.js',
exposes: {
'./ResultsPage': './src/pages/ResultsPage',
'./Test1Page' : './src/pages/Test1Page',
'./Test2Page' : './src/pages/Test2Page',
'./appStore' : './src/store/appStore.js'
},
shared: require("./package.json").dependencies,
}),
],
}
})
And the package.json:
{
"name": "child2",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint"
},
"dependencies": {
"#vue/composition-api": "^1.7.0",
"core-js": "^3.8.3",
"pinia": "^2.0.17",
"vue": "^2.6.14",
"vue-router": "^4.1.5"
},
"devDependencies": {
"#babel/core": "^7.12.16",
"#babel/eslint-parser": "^7.12.16",
"#vue/cli-plugin-babel": "~5.0.8",
"#vue/cli-plugin-eslint": "~5.0.8",
"#vue/cli-plugin-router": "~5.0.8",
"#vue/cli-plugin-unit-mocha": "~5.0.8",
"#vue/cli-service": "~5.0.8",
"#vue/test-utils": "^1.1.3",
"chai": "^4.2.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"sass": "^1.32.7",
"sass-loader": "^12.0.0",
"vue-cli-plugin-pinia": "~0.1.4",
"vue-template-compiler": "^2.6.14"
}
}
Parent: This is how works vue.config.js
const { defineConfig } = require("#vue/cli-service");
const { ModuleFederationPlugin } = require("webpack").container;
const ExternalTemplateRemotesPlugin = require("external-remotes-plugin");
const deps = require("./package.json");
module.exports = defineConfig({
transpileDependencies: true,
configureWebpack: {
plugins: [
new ModuleFederationPlugin({
name: "microfrontends-library",
remotes: {
child1: "child1#http://localhost:3013/remoteEntry.js",
//child2: "child2#http://localhost:3014/remoteEntry.js",
},
shared: require('./package.json').dependencies,
})
],
},
});
And its package.json
{
"name": "parent",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint"
},
"dependencies": {
"#vue/composition-api": "^1.7.0",
"core-js": "^3.8.3",
"pinia": "^2.0.17",
"vue": "^2.6.14",
"vue-router": "^4.1.5"
},
"devDependencies": {
"#babel/core": "^7.12.16",
"#babel/eslint-parser": "^7.12.16",
"#vue/cli-plugin-babel": "~5.0.0",
"#vue/cli-plugin-eslint": "~5.0.0",
"#vue/cli-plugin-router": "~5.0.0",
"#vue/cli-plugin-unit-jest": "~5.0.0",
"#vue/cli-service": "~5.0.0",
"#vue/test-utils": "^1.1.3",
"#vue/vue2-jest": "^27.0.0-alpha.2",
"babel-jest": "^27.0.6",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"jest": "^27.0.5",
"sass": "^1.32.7",
"sass-loader": "^12.0.0",
"vue-cli-plugin-pinia": "~0.1.4",
"vue-template-compiler": "^2.6.14"
}
}
In resume: I don't have a HTTP server because I'm making a build of the child and them using a HTTP server for support ( In the future I would like to add CDN to this children's )
All help would be accepted, really I'm in a stuck solution, so any movement to a solution would be great
// vue.config.js
module.exports = {
configureWebpack: {
module: {
rules: [
{
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto"
}
]
}
}
}
I find this solution in answer
Works for me
I create project through vue cli with options: vue3, TS, JEST and add #testing-library/vue . my package.json looks like this
{
"name": "todo-app",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint"
},
"dependencies": {
"vue": "^3.0.0",
"vue-class-component": "^8.0.0-0",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0"
},
"devDependencies": {
"#testing-library/vue": "^5.8.2",
"#types/jest": "^24.0.19",
"#typescript-eslint/eslint-plugin": "^4.18.0",
"#typescript-eslint/parser": "^4.18.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-plugin-router": "~4.5.0",
"#vue/cli-plugin-typescript": "~4.5.0",
"#vue/cli-plugin-unit-jest": "~4.5.0",
"#vue/cli-plugin-vuex": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/compiler-sfc": "^3.0.0",
"#vue/eslint-config-standard": "^5.1.2",
"#vue/eslint-config-typescript": "^7.0.0",
"#vue/test-utils": "^2.0.0-0",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^7.0.0",
"node-sass": "^4.12.0",
"sass-loader": "^8.0.2",
"typescript": "~4.1.5",
"vue-jest": "^5.0.0-0"
}
}
my jest.config.js is the one I am getting from vue CLI
module.exports = {
preset: '#vue/cli-plugin-unit-jest/presets/typescript',
transform: {
'^.+\\.vue$': 'vue-jest'
}
}
my test is
import { fireEvent, render, waitFor } from '#testing-library/vue';
import ContentBlock from '#/components/ContentBlock.vue';
describe('ContentBlock.spec.vue', () => {
const mockedProps = {
title: 'testTitle',
content: 'testTitle',
btn: 'testBtnText'
}
const getMountedInstance = () => {
return render(ContentBlock, {
props: mockedProps
});
};
it('renders block title, content and button', async (): Promise<void> => {
const { getByTestId } = getMountedInstance();
const [title, content, btn] = await waitFor(() => {
return [
getByTestId('blockTitle'),
getByTestId('blockContent'),
getByTestId('blockBtn'),
];
});
expect(title).toBeDefined();
expect(title).toContain(mockedProps.title);
expect(content).toBeDefined();
expect(content).toContain(mockedProps.content);
expect(btn).toBeDefined();
expect(content).toContain(mockedProps.btn);
});
})
tried node versions: 14, 12
I am getting error:
Test suite failed to run
Cannot find module 'vue-template-compiler' from 'vue-test-utils.js'
However, Jest was able to find:
'./render.js'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'jsx', 'json', 'vue', 'ts', 'tsx'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
I checked similar questions such as Test suite failed to run Cannot find module 'vue-template-compiler when using jest in vue3 but it did not help me.
ah, I managed to find an answer in https://github.com/testing-library/vue-testing-library/issues/176
install this version of library #testing-library/vue#next such as
yarn add -D #testing-library/vue#next
or
npm i --save-dev #testing-library/vue#next