Lost styles using Vuetify 2.0.4 - vue.js

I'm having difficulty updating an existing project with Vuetify 2.0.4. I'm fairly sure I'm initializing Vuetify correctly - when I refreshed my app I noticed that breaking changes in Vuetify (e.g. round vs rounded) were being picked up, but once I'd fixed those, all I was left with was an unstyled app with error messages of the form
[Vue warn]: Unknown custom element: <v-app> - did you register the component correctly?
for every Vuetify tag () in my code.
I'm wondering if my problem lies with my attempt to parse .sass files (in webpack.mix.js), but bottom line, I'm totally lost in space here and would appreciate some direction.
Thanks, Tom.
app.js
require('./bootstrap');
import i18n from './i18n.js';
import Vue from 'vue';
import Vuetify from 'vuetify/lib'
import router from './routes.js';
import { store } from './store/store.js';
import VueUtils from './plugins/vue-utils.js';
Vue.prototype.$http = axios;
import Exception from './helpers/Exception'
window.Exception = Exception;
import App from "./components/App.vue";
import Navbar from './components/nav/NavBar.vue';
import Footer from './components/nav/Footer.vue';
import SwitchLanguage from './components/tools/SwitchLanguage.vue';
import SocialMedia from './components/tools/SocialMedia.vue';
import ReturnButton from './components/tools/ReturnButton.vue';
import RelistButton from './components/tools/RelistButton.vue';
import WarningNotification from './components/tools/WarningNotification.vue';
import QuestionButton from './components/tools/QuestionButton.vue';
import Vuelidate from 'vuelidate';
Vue.config.productionTip = true;
Vue.use(VueUtils);
Vue.use(Vuelidate);
Vue.use(require('vue-moment'));
const vuetifyOptions = {
theme: {
dark: true,
}
};
Vue.use(Vuetify);
Vue.component('my-navbar', Navbar);
Vue.component('my-footer', Footer);
Vue.component('switch-language', SwitchLanguage);
Vue.component('social-media', SocialMedia);
Vue.component('return-button', ReturnButton);
Vue.component('relist-button', RelistButton);
Vue.component('warning-notification', WarningNotification);
Vue.component('question-button', QuestionButton);
export const eventBus = new Vue();
new Vue({
store,
i18n,
router,
vuetify: new Vuetify(vuetifyOptions),
render: h => h(App)
}).$mount("#app");
package.json
{
"name": "herdingcats",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"wrkbox": "workbox injectManifest && npm run dev"
},
"dependencies": {
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"caniuse-lite": "^1.0.30000985",
"connect-history-api-fallback": "^1.6.0",
"core-js": "^3.1.4",
"css-loader": "^3.1.0",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"html2plaintext": "^2.1.2",
"idb": "^4.0.4",
"laravel-echo": "^1.5.4",
"libphonenumber-js": "^1.7.21",
"lodash.uniq": "^4.5.0",
"material-design-icons-iconfont": "^5.0.1",
"popper": "^1.0.1",
"pusher-js": "^5.0.0",
"register-service-worker": "^1.6.2",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"vue-faq-accordion": "^1.2.1",
"vue-i18n": "^8.12.0",
"vue-moment": "^4.0.0",
"vue-router": "^3.0.7",
"vue-socialmedia-share": "^1.0.1",
"vue-tel-input": "^2.5.0",
"vuelidate": "^0.7.4",
"vuetify": "^2.0.3",
"vuetify-loader": "^1.3.0",
"vuex": "^3.1.1",
"vuex-i18n": "^1.11.0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "^3.9.2",
"#vue/cli-plugin-eslint": "^3.9.2",
"#vue/cli-plugin-pwa": "^3.9.0",
"#vue/cli-service": "^3.9.3",
"axios": "^0.19.0",
"babel-eslint": "^10.0.2",
"bootstrap": "^4.3.1",
"cross-env": "^5.2",
"deepmerge": "^4.0.0",
"eslint": "^6.1.0",
"eslint-plugin-vue": "^5.2.3",
"eslint-plugin-vuetify": "^1.0.0-beta.3",
"fibers": "^4.0.1",
"friendly-errors-webpack-plugin": "~1.7",
"jquery": "^3.4",
"laravel-mix": "^4.1.2",
"mini-css-extract-plugin": "^0.8.0",
"popper.js": "^1.15",
"raw-loader": "^3.1.0",
"resolve-url-loader": "^3.1.0",
"sass": "^1.22.9",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"vue": "^2.6.10",
"vue-cli-plugin-vuetify": "^0.6.1",
"vue-template-compiler": "^2.6.10",
"webpack": "^4.37.0",
"webpack-cli": "^3.3.6",
"webpack-dev-server": "^3.7.2",
"workbox-cli": "^4.3.1"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
vue.config.js
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin')
module.exports = {
runtimeCompiler: true,
configureWebpack: {
plugins: [
new VuetifyLoaderPlugin()
],
rules: [
{
test: /\.s(c|a)ss$/,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
implementation: require('sass'),
fiber: require('fibers'),
indentedSyntax: true // optional
}
}
]
}
]
},
};
webpack.mix.js
let mix = require('laravel-mix');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
//mix.js('resources/js/app.js', 'dist/').sass('resources/sass/app.scss', 'dist/');
mix.js('resources/js/app.js', 'public/js').sass('resources/sass/app.scss', 'public/css');
mix.webpackConfig({
plugins: [
//new BundleAnalyzerPlugin(),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
})
],
// module: {
// rules: [{
// test: /\.scss$/,
// use: [
// //fallback to style-loader in development
// process.env.NODE_ENV !== 'production' ? 'style-loader' : MiniCssExtractPlugin.loader,
// "css-loader",
// "sass-loader"
// // {
// // loader: 'sass-loader',
// // options: {
// // implementation: require('sass'),
// // fiber: require('fibers'),
// // }
// // }
// ]
// }]
// },
}
);
app.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="apple-touch-icon" sizes="57x57" href="images/apple-icon-57x57.png"> ...
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">
<link rel="manifest" href="./manifest.json">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="SafeVegetables">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-TileImage" content="images/mstile-144x144.png">
<meta name="theme-color" content="#9CCC65">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>XXXX</title>
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900' rel="stylesheet">
<script type='text/javascript'>
window.Laravel = <?php echo json_encode([
'csrfToken' => csrf_token(),
]); ?>
</script>
</head>
<body>
<noscript>
<p>We're sorry but this site doesn't work properly without JavaScript enabled. Please enable it to continue.</p>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
<script type="text/javascript" src="{{ asset('js/app.js') }}"></script>
<script>
let newWorker;
function showUpdateBar() {
let snackbar = document.getElementById('snackbar');
snackbar.className = 'show';
};
// The click event on the pop up notification
document.getElementById('reload').addEventListener('click', function(){
newWorker.postMessage({ action: 'skipWaiting' });
});
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('sw.js')
.then(registration => {
console.log(`Service Worker was registered! Scope: ${registration.scope}`);
})
.catch(err => {
console.log(`Service Worker registration failed: ${err}`);
});
});
}
</script>
</body>
</html>

Related

Jest don't mount composition-api component on Vue 2.7 + TS + Vuetify with "vue-test-utils"

I'm trying to run unit test for composition-api component. I'm on Vue 2.7 with TS and the following packages:
"nuxt": "^2.15.8",
"#nuxtjs/composition-api": "^0.33.1",
"#vue/test-utils": "^1.3.0",
"jest": "^28.1.3",
The issue is the following error is thrown on component mount:
SyntaxError: Unexpected token (1:1141)
at Parser.pp$4.raise (node_modules/vue-template-es2015-compiler/buble.js:2757:13)
at Parser.pp.unexpected (node_modules/vue-template-es2015-compiler/buble.js:647:8)
at Parser.pp$3.parseExprAtom (node_modules/vue-template-es2015-compiler/buble.js:2196:10)
at Parser.<anonymous> (node_modules/vue-template-es2015-compiler/buble.js:6003:24)
at Parser.parseExprAtom (node_modules/vue-template-es2015-compiler/buble.js:6129:31)
at Parser.pp$3.parseExprSubscripts (node_modules/vue-template-es2015-compiler/buble.js:2047:19)
at Parser.pp$3.parseMaybeUnary (node_modules/vue-template-es2015-compiler/buble.js:2024:17)
at Parser.pp$3.parseExprOps (node_modules/vue-template-es2015-compiler/buble.js:1966:19)
at Parser.pp$3.parseMaybeConditional (node_modules/vue-template-es2015-compiler/buble.js:1949:19)
at Parser.pp$3.parseMaybeAssign (node_modules/vue-template-es2015-compiler/buble.js:1925:19)
The test example:
import { mount, createLocalVue } from '#vue/test-utils';
import CompositionApi from '#nuxtjs/composition-api';
import CustomSelect from '#/components/shared/CustomSelect';
import Vuetify from 'vuetify';
const localVue = createLocalVue();
localVue.use(CompositionApi);
let vuetify;
beforeEach(() => {
jest.clearAllMocks();
vuetify = new Vuetify();
});
describe('test select component', () => {
test('Mounts correclty', () => {
const wrapper = mount(CustomSelect, {
localVue,
vuetify,
});
expect(wrapper.vm).toBeTruthy();
});
});
The config:
// jest.config.js
module.exports = {
globalSetup: '<rootDir>/jest.setup.js',
setupFiles: ['<rootDir>/tests/jest.init.js'],
testEnvironment: 'jsdom',
moduleNameMapper: {
'^#/(.*)$': '<rootDir>/$1',
'^~/(.*)$': '<rootDir>/$1',
'^vue$': 'vue/dist/vue.common.js',
'^#nuxtjs/composition-api$':
'#nuxtjs/composition-api/dist/runtime/index.js',
},
moduleFileExtensions: ['js', 'vue', 'json'],
transform: {
'^.+\\.js$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest',
'^.+\\.ts?$': 'ts-jest',
'.+\\.(css|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
},
transformIgnorePatterns: [
'<rootDir>/node_modules/(?!(#nuxtjs/composition-api)/)',
],
snapshotSerializers: ['jest-serializer-vue'],
testMatch: ['<rootDir>/tests/unit/**/*.spec.js'],
};
package.json
{
.....
"test": "jest",
"test:watch": "jest --watch",
.....
},
"engines": {
"npm": "8.11",
"node": "16.16"
},
"dependencies": {
.....
"#babel/eslint-parser": "^7.18.9",
"#nuxt/types": "^2.15.8",
"#nuxt/typescript-build": "^2.1.0",
"#nuxtjs/composition-api": "^0.33.1",
"#nuxtjs/vuetify": "^1.12.3",
"#vueuse/core": "^9.3.1",
"flush-promises": "^1.0.2",
"jest-environment-jsdom": "^28.1.3",
"jest-mock-axios": "^4.7.0-beta",
"nuxt": "^2.15.8",
.....
},
"devDependencies": {
.....
"#babel/core": "^7.19.1",
"#babel/preset-env": "^7.19.1",
"#faker-js/faker": "^7.6.0",
"#vue/server-test-utils": "^1.3.0",
"#vue/test-utils": "^1.3.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^28.1.3",
"eslint": "^8.20.0",
"jest": "^28.1.3",
"jest-cli": "^28.1.3",
"jest-serializer-vue": "^2.0.2",
"jest-transform-stub": "^2.0.0",
"mockdate": "^3.0.2",
"vue-jest": "^3.0.7"
.....
}
}
I've tried all the suggestions from Jest docs, including: specifying "transformIgnorePatterns", specifying "moduleNameMapper", enabling "ECMAScript Modules" but it won't help.
What should be the working setup to test composition-api components on Vue 2.7 + Nuxt + Vuetify?

I get Cannot use import statement outside a module error while unit testing with Jest in quasar

I want to test my quasar application with jest, when i run the test i get error
SyntaxError: Cannot use import statement outside a module
58 | </template>
59 | <script>
> 60 | import { QCalendarDay, today } from '#quasar/quasar-ui-qcalendar/src/index.js'
| ^
61 | import '#quasar/quasar-ui-qcalendar/src/QCalendarVariables.sass'
62 | import '#quasar/quasar-ui-qcalendar/src/QCalendarTransitions.sass'
63 | import '#quasar/quasar-ui-qcalendar/src/QCalendarDay.sass'
root/src/components/calendars/daily-calendar
div(style="display: flex")
q-calendar-day.rounded-borders(ref="dailyCalendar" :locale="localeLanguage" :hour24-format="true" :interval-minutes="appointmentDuration" v-model="selectedDate" view="day" animated bordered transition-next="slide-left" transition-prev="slide-right" no-active-date :interval-start="24" :interval-count="68" :interval-height="28")
template(#head-day-event="{ scope: { timestamp } }")
div(style="display: flex; justify-content: center; flex-wrap: wrap; padding: 2px")
template(v-for="event in modelValueProxy[timestamp.date]" :key="event.id")
q-badge(v-if="!event.time" :class="badgeClasses(event, 'header')" :style="badgeStyles(event, 'header')" style="width: 100%; cursor: pointer; height: 12px; font-size: 10px; margin: 1px")
.title.q-calendar__ellipsis
| {{ event.title }}
daily calendar script
import { QCalendarDay, today } from '#quasar/quasar-ui-qcalendar/src/index.js'
import '#quasar/quasar-ui-qcalendar/src/QCalendarVariables.sass'
import '#quasar/quasar-ui-qcalendar/src/QCalendarTransitions.sass'
import '#quasar/quasar-ui-qcalendar/src/QCalendarDay.sass'
import lookie from 'lookie'
import moment from 'moment'
import { date } from 'quasar'
import { defineComponent } from 'vue'
export default defineComponent({
name: 'WeekSlotDayBody',
components: {
QCalendarDay
},
root/test/jest/tests/dailyCalendar.spec.ts
import { describe, expect, it } from '#jest/globals'
import { installQuasarPlugin } from '#quasar/quasar-app-extension-testing-unit-jest'
import { mount } from '#vue/test-utils'
import dailyCalendar from '#/components/calendars/daily-calendar.vue'
/*
* You can provide a config object as param like such:
*
* ```ts
* installQuasarPlugin({ plugins: { Dialog } });
* ```
*/
installQuasarPlugin()
describe('dailyCalendar', () => {
it('mounts without errors', () => {
const wrapper = mount(dailyCalendar)
expect(wrapper).toBeTruthy()
})
})
jest.config.js
const esModules = ['quasar', 'quasar/lang', 'lodash-es'].join('|')
/* eslint-env node */
module.exports = {
globals: {
__DEV__: true,
// TODO: Remove if resolved natively
// See https://github.com/vuejs/vue-jest/issues/175
'vue-jest': {
pug: { doctype: 'html' }
},
// Remove if using `const enums`
// See https://huafu.github.io/ts-jest/user/config/isolatedModules#example
'ts-jest': {
isolatedModules: true
}
},
roots: ['<rootDir>/../'],
modulePaths: ['<rootDir>/../'],
moduleDirectories: ['node_modules'],
// Jest assumes we are testing in node environment, specify jsdom environment instead
testEnvironment: 'jsdom',
// noStackTrace: true,
// bail: true,
// cache: false,
// verbose: true,
// watch: true,
collectCoverage: false,
coverageDirectory: '<rootDir>/test/jest/coverage',
coverageReporters: ['json-summary'],
collectCoverageFrom: [
'<rootDir>/src/**/*.vue',
'<rootDir>/src/**/*.js',
'<rootDir>/src/**/*.ts',
'<rootDir>/src/**/*.jsx',
'<rootDir>/src/**/*.tsx'
],
coveragePathIgnorePatterns: ['/node_modules/', '.d.ts$'],
coverageThreshold: {
global: {
// branches: 50,
// functions: 50,
// lines: 50,
// statements: 50
}
},
testMatch: [
// Matches tests in any subfolder of 'src' or into 'test/jest/__tests__'
// Matches all files with extension 'js', 'jsx', 'ts' and 'tsx'
'<rootDir>/test/jest/__tests__/**/*.(spec|test).+(ts|js)?(x)',
'<rootDir>/src/**/*.jest.(spec|test).+(ts|js)?(x)'
],
// Extension-less imports of components are resolved to .ts files by TS,
// grating correct type-checking in test files.
// Being 'vue' the first moduleFileExtension option, the very same imports
// will be resolved to .vue files by Jest, if both .vue and .ts files are
// in the same folder.
// This guarantee a great dev experience both for testing and type-checking.
// See https://github.com/vuejs/vue-jest/issues/188#issuecomment-620750728
moduleFileExtensions: ['vue', 'js', 'jsx', 'json', 'ts', 'tsx'],
moduleNameMapper: {
'^quasar$': 'quasar/dist/quasar.esm.prod.js',
'^~/(.*)$': '<rootDir>/$1',
'^src/(.*)$': '<rootDir>/src/$1',
'^app/(.*)$': '<rootDir>/$1',
'^components/(.*)$': '<rootDir>/src/components/$1',
'^layouts/(.*)$': '<rootDir>/src/layouts/$1',
'^pages/(.*)$': '<rootDir>/src/pages/$1',
'^assets/(.*)$': '<rootDir>/src/assets/$1',
'^boot/(.*)$': '<rootDir>/src/boot/$1',
'.*css$': '#quasar/quasar-app-extension-testing-unit-jest/stub.css'
},
transform: {
// See https://jestjs.io/docs/en/configuration.html#transformignorepatterns-array-string
[`^(${esModules}).+\\.js$`]: 'babel-jest',
'^.+\\.(ts|js|html)$': 'ts-jest',
// vue-jest uses find-babel-file, which searches by this order:
// (async) .babelrc, .babelrc.js, package.json, babel.config.js
// (sync) .babelrc, .babelrc.js, babel.config.js, package.json
// https://github.com/tleunen/find-babel-config/issues/33
'.*\\.vue$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub'
},
transformIgnorePatterns: [`node_modules/(?!(${esModules}))`],
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue']
}
Error
Cannot find module '#/components/calendars/daily-calendar.vue' from 'test/jest/__tests__/MyButton.spec.ts'
package.json
{
"private": true,
"scripts": {
"dev": "quasar dev",
"build": "quasar build",
"start": "node server.js",
"lint": "eslint --ext .js,.ts,.vue ./",
"format": "prettier --write \"**/*.{js,ts,vue,scss,html,md,json}\" --ignore-path .gitignore",
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
"heroku-postbuild": "yarn && yarn build",
"make-badges": "istanbul-badges-readme",
"test:unit:ui": "majestic",
"test:unit": "jest --updateSnapshot",
"test:unit:ci": "jest --ci",
"test:unit:coverage": "jest --coverage",
"test:unit:watch": "jest --watch",
"test:unit:watchAll": "jest --watchAll",
"serve:test:coverage": "quasar serve test/jest/coverage/lcov-report/ --port 8788",
"concurrently:dev:jest": "concurrently \"quasar dev\" \"jest --watch\""
},
"dependencies": {
"#fortawesome/fontawesome-svg-core": "^6.1.1",
"#fortawesome/free-regular-svg-icons": "^6.1.1",
"#fortawesome/free-solid-svg-icons": "^6.1.1",
"#fortawesome/vue-fontawesome": "^3.0.0-5",
"#quasar/cli": "^1.3.2",
"#quasar/extras": "^1.13.6",
"#types/lodash-es": "^4.17.6",
"#vue/test-utils": "^2.0.0-rc.18",
"axios": "^0.27.2",
"connect-history-api-fallback": "^1.6.0",
"core-js": "^3.22.3",
"crypto": "^1.0.1",
"crypto-browserify": "^3.12.0",
"echarts": "^5.3.2",
"express": "^4.18.1",
"froala-editor": "^4.0.11",
"happy-dom": "^6.0.4",
"include-media": "^1.4.10",
"lodash-es": "^4.17.21",
"lookie": "^1.0.4",
"moment": "^2.29.3",
"moment-business-days": "^1.2.0",
"moment-timezone": "^0.5.34",
"quasar": "^2.7.5",
"reactive-state": "^3.7.2",
"sass": "^1.52.1",
"serve-static": "^1.15.0",
"stream-browserify": "^3.0.0",
"ui": "^0.2.4",
"vitest": "^0.18.1",
"vue": "^3.2.33",
"vue-echarts": "^6.0.2",
"vue-froala-wysiwyg": "^4.0.11",
"vue-i18n": "^9.2.0-beta.36",
"vue-jest": "^5.0.0-alpha.10",
"vue-moment-tz": "^2.1.1",
"vue-router": "^4.0.14",
"yarn": "^1.22.18"
},
"devDependencies": {
"#prettier/plugin-pug": "^2.0.0",
"#quasar/app-webpack": "^3.5.3",
"#quasar/quasar-app-extension-qcalendar": "^4.0.0-beta.15",
"#quasar/quasar-app-extension-testing": "^2.0.4",
"#quasar/quasar-app-extension-testing-unit-jest": "^3.0.0-alpha.10",
"#types/node": "^17.0.29",
"#typescript-eslint/eslint-plugin": "^5.21.0",
"#typescript-eslint/parser": "^5.21.0",
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^25.2.2",
"eslint-plugin-vue": "^8.7.1",
"eslint-webpack-plugin": "^3.1.1",
"istanbul-badges-readme": "^1.8.2",
"majestic": "^1.7.0",
"prettier": "^2.6.2",
"pug": "^3.0.2",
"pug-plain-loader": "^1.1.0",
"workbox-webpack-plugin": "^6.5.3"
},
"browser": {
"crypto": false,
"stream": false
},
"browserslist": [
"last 10 Chrome versions",
"last 10 Firefox versions",
"last 4 Edge versions",
"last 7 Safari versions",
"last 8 Android versions",
"last 8 ChromeAndroid versions",
"last 8 FirefoxAndroid versions",
"last 10 iOS versions",
"last 5 Opera versions"
],
"engines": {
"node": ">= 12.22.1",
"npm": ">= 6.13.4",
"yarn": ">= 1.21.1"
},
"overrides": {
"#types/eslint": "8.4.3"
},
"resolutions": {
"#types/eslint": "8.4.3"
}
}
When I run the above gesture conf, I get module not found error. this config is actually the config that comes when loading jest with quasar. I don't understand why I am getting such an error.
Remove nonexistent /calendars folder from your import path:
import dailyCalendar from '#/components/calendars/daily-calendar.vue'
Should be updated to:
import dailyCalendar from '#/components/daily-calendar.vue'
The import is looking for a file path that doesn't exist, given that the actual file is at root/src/components/daily-calendar and #/ is mapped to root/src. If the actual file path was root/src/components/calendars/daily-calendar, the import would work.

Having issues with vue-svg-loader - missing template or render function

I am getting issues trying to get vue-svg-loader to work. I posted this in the issues part of the plugin, but I am not sure if it is, or just that I have implemented it wrong.
I am pretty new to Vue, so apologies if I am making a really stupid mistake when implementing it.
When I run vue --version it says I am on #vue/cli 4.5.9
This is the code inside of my component:
<template>
<div>
<SampleSvg />
</div>
</template>
<script>
import SampleSvg from "#/assets/sample.svg"
export default {
name: "HelloWorld",
components: {
SampleSvg
},
};
</script>
This is my vue.config.js file:
module.exports = {
chainWebpack: (config) => {
const svgRule = config.module.rule('svg');
svgRule.uses.clear();
svgRule
.use('babel-loader')
.loader('babel-loader')
.end()
.use('vue-svg-loader')
.loader('vue-svg-loader');
},
css: {
loaderOptions: {
sass: {
prependData:
`#import "#/assets/scss/globals/_variables.scss";
#import "#/assets/scss/globals/_variables-font-sizes.scss";
#import "#/assets/scss/globals/_colours.scss";
#import "#/assets/scss/globals/_mixins.scss";
`
},
},
},
};
This is my package.json file
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.21.1",
"core-js": "^3.6.5",
"postcss": "^8.3.6",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-plugin-router": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/compiler-sfc": "^3.0.0",
"#vue/eslint-config-prettier": "^6.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.0.0",
"prettier": "^2.2.1",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"style-resources-loader": "^1.4.1",
"vue-svg-loader": "^0.17.0-beta.2",
"vue-template-compiler": "^2.6.14"
}
}
The error I get is:
[Vue warn]: Component is missing template or render function.
at <SampleSvg>
at <HelloWorld onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< null > >
at <RouterView>
at <App>
If I open up the sample.svg file, I have this code:
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
<circle cx="50" cy="50" r="40" stroke="deeppink" stroke-width="2" fill="#ffe6ee" />
</svg>
I am pretty new to Vue, so apologies if this is down to how I have installed it.
My setup is as follows - but since I want to reference both internal and external SVGs (meaning that I want to be able to import an SVG as a Vue Component OR to be able to put it in the SRC of an IMG tag) I use the ?int modifier to signal when I want to receive a component. Without this modifier the import will be the image itself.
const svgRule = config.module.rule('svg');
svgRule.uses.clear();
svgRule
.oneOf('inline')
.resourceQuery(/int/) // internal SVGs must be in the form - import svgComponent from "#/images/example.svg?int" !!!!!
.use('babel-loader')
.loader('babel-loader')
.end()
.use('vue-svg-loader')
.loader('vue-svg-loader')
.options({
svgo:
{
plugins: [
{ inlineStyles: { onlyMatchedOnce: false } },
{ removeXMLNS: true },
{ removeViewBox: false },
{ removeDimensions: true },
]
}
})
.end()
.end()
.oneOf('external')
.use('url-loader')
.loader('url-loader')
.options({
limit: 4096,
fallback:
{
loader: 'file-loader',
options:
{
name: 'img/[name].[hash:8].[ext]',
}
}
});

Vue App Blank page in IE-11 and Ms Edge 40

I was given a Vue app that is working perfectly in Chrome, Firefox.
But blank page in IE-11 and Ms Edge. No Erorrs in console.
I'm not a Vue developer but I'm interested in Vue. So Tried to find a solution googling it. But no of those solutions works for me. Can someone please tell me what should I do to fix this blank page issue in IE-11 & Edge?.
main.js
import 'babel-polyfill'
import Vue from 'vue'
import Request from './http/request'
const EXCLUDED_PROD = [
'52.59.217.237',
'localhost'
]
babel.config.js
module.exports = {
presets: [
['#vue/app', {
polyfills: [
'es6.promise',
'es6.symbol'
]
}]
]
}
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>fav.png">
<title>Starline Security</title>
</head>
<body>
<noscript>
<strong>We're sorry but Starline Security doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!--built files will be auto injected-->
</body>
</html>
package.json
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
How do you create your vue project? I create vue project according to this link and choose default. It can run well in IE and Edge without installing other packages.
I compared the files in the working project with yours and the babel.config.js and package.json are different. You could try to edit your babel.config.js and package.json according to below.
babel.config.js:
module.exports = {
presets: [
'#vue/cli-plugin-babel/preset'
]
}
package.json:
{
"name": "hello-world",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^2.6.11"
},
"devDependencies": {
"#vue/cli-plugin-babel": "^4.4.0",
"#vue/cli-plugin-eslint": "^4.4.0",
"#vue/cli-service": "^4.4.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
Besides, it seems that your main.js is not complete. Mine is like this:
import Vue from 'vue'
import App from './App.vue'
Vue.config.productionTip = false
new Vue({
render: h => h(App),
}).$mount('#app')

Vue 2.0 No render conent slot

I'm using Vue 2.0 standalone and i have a problem with components with Slot. Always render default value inside slot. Never render content inside custom component
package.json
{
"name": "web-components",
"description": "A Vue.js project",
"author": "",
"private": true,
"scripts": {
"watchify": "watchify -vd -p browserify-hmr -e src/main.js -o dist/build.js",
"serve": "http-server -o -c 1 -a localhost",
"dev": "npm-run-all --parallel watchify serve",
"lint": "eslint --ext .js,.vue src test/unit",
"test": "karma start karma.conf.js",
"build": "cross-env NODE_ENV=production browserify -g envify -p [ vueify/plugins/extract-css -o dist/build.css ] -e src/main.js | uglifyjs -c warnings=false -m > dist/build.js"
},
"browserify": {
"transform": [
"vueify",
"babelify"
]
},
"aliasify": {
"aliases": {
"vue": "vue/dist/vue"
}
},
"dependencies": {
"vue": "^2.0.1"
},
"devDependencies": {
"aliasify": "^2.0.0",
"babel-core": "^6.0.0",
"babel-plugin-transform-runtime": "^6.0.0",
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-2": "^6.0.0",
"babel-runtime": "^6.0.0",
"babelify": "^7.2.0",
"browserify": "^13.1.0",
"browserify-hmr": "^0.3.1",
"cross-env": "^2.0.0",
"envify": "^3.4.1",
"eslint": "^3.3.0",
"eslint-config-standard": "^5.3.5",
"eslint-plugin-html": "^1.5.2",
"eslint-plugin-promise": "^2.0.1",
"eslint-plugin-standard": "^2.0.0",
"http-server": "^0.9.0",
"jasmine-core": "^2.4.1",
"karma": "^1.2.0",
"karma-browserify": "^5.1.0",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.0",
"karma-spec-reporter": "0.0.26",
"npm-run-all": "^2.3.0",
"phantomjs-prebuilt": "^2.1.3",
"proxyquireify": "^3.0.1",
"uglify-js": "^2.5.0",
"vueify": "^9.0.0",
"watchify": "^3.4.0"
}
}
main.js
//this show Failed to mount component: template or render function not defined.
//import Vue from 'vue/dist/vue'
import Vue from 'vue'
import Hello from './components/Hello.vue'
Vue.component('Hello',Hello)
new Vue({ // eslint-disable-line no-new
el: '#app'
});
Hello.vue
<template>
<div id="hello">
<h1>{{ msg }}</h1>
<slot>defect</slot>
</div>
</template>
<script>
export default {
name: 'hello',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script>
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>web-components</title>
<link rel="stylesheet" href="dist/build.css">
</head>
<body>
<div id="app">
<hello><label>change value</label></hello>
</div>
<script src="dist/build.js"></script>
</body>
</html>
EDIT: If i use npm run build instead of nrpm run dev. This work fine.
It's likely you're using the "runtime-only" build. If you're using that then all your templates must be in Vue files. Since your app's template is in the index.html it won't work. So either put your apps template into a Vue file and render that or use the "Runtime + Compiler" build. You can read more about that here: http://vuejs.org/guide/installation.html#Standalone-vs-Runtime-only-Build