How to use "v-owl-carousel" with nuxt and vuetify? - vue.js

I am working on a Nuxt app and using "Vuetify" as my frontend framework. In one of my pages I decided to use "v-owl-carousel" for making a carousel. The code of that page is below:
<template>
<v-container>
<v-row>
<v-col cols="12">
<client-only> <!-- important to add no-ssr-->
<carousel :autoplay="true" :number="6">
<v-card>
<img :src="require(`~/assets/imgs/books/07.webp`)">
</v-card>
<v-card>
<img :src="require(`~/assets/imgs/books/02.webp`)">
</v-card>
<v-card>
<img :src="require(`~/assets/imgs/books/03.webp`)">
</v-card>
<v-card>
<img :src="require(`~/assets/imgs/books/04.webp`)">
</v-card>
<v-card>
<img :src="require(`~/assets/imgs/books/05.webp`)">
</v-card>
<v-card>
<img :src="require(`~/assets/imgs/books/06.webp`)">
</v-card>
</carousel>
</client-only>
</v-col>
</v-row>
</v-container>
</template>
The problem here is that only 3 image of all images are shown in the carousel and when the carousel loops it shows nothing until it comes back to that 3 image. I find out that if I comment the "v-app" in my default.vue layout like below code, it works correctly:
<template>
<!--
<v-app dark lang="fa" dir="rtl">
<the-nanigation />
<v-main>
-->
<div id="mainContent">
<nuxt />
</div>
<!--
</v-main>
</v-app>
-->
</template>
But according to Vuetify documentation we must use v-app in our applications. So what is the solution to use v-owl-carousel in my app that uses Vuetify.

Alright, I did it for you here on this github repo: https://github.com/kissu/so-vuetify-awesome-swiper
It is mainly this
nuxt.config.js file
import colors from 'vuetify/es5/util/colors'
export default {
ssr: false,
target: 'static',
head: {
titleTemplate: '%s - so-vuetify-awesome-swiper',
title: 'so-vuetify-awesome-swiper',
htmlAttrs: {
lang: 'en',
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' },
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
components: true,
buildModules: ['#nuxtjs/eslint-module', '#nuxtjs/vuetify'],
modules: ['#nuxtjs/axios'],
vuetify: {
customVariables: ['~/assets/variables.scss'],
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,
},
},
},
},
}
This package.json
{
"name": "so-vuetify-awesome-swiper",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint": "yarn lint:js"
},
"dependencies": {
"#nuxtjs/axios": "^5.13.6",
"core-js": "^3.15.1",
"nuxt": "^2.15.7",
"swiper": "^6.8.4",
"vue-awesome-swiper": "^4.1.1",
"vuetify": "^2.5.5"
},
"devDependencies": {
"#babel/eslint-parser": "^7.14.7",
"#nuxtjs/eslint-config": "^6.0.1",
"#nuxtjs/eslint-module": "^3.0.2",
"#nuxtjs/vuetify": "^1.12.1",
"eslint": "^7.29.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-nuxt": "^2.0.0",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-vue": "^7.12.1",
"prettier": "^2.3.2"
}
}
And here is the .vue component that I've created
<template>
<div>
<p>Amazin swiper huh? 😄</p>
<swiper :options="swiperOptions" class="swiper">
<swiper-slide v-for="image in gallery" :key="image.id">
<img :src="image.src" />
</swiper-slide>
<div
v-show="prevSlideAvailable"
slot="button-prev"
#click="$refs.swiper.$swiper.slidePrev()"
></div>
<div
v-show="nextSlideAvailable"
slot="button-next"
#click="$refs.swiper.$swiper.slideNext()"
></div>
</swiper>
</div>
</template>
<script>
import { Swiper, SwiperSlide } from 'vue-awesome-swiper'
import 'swiper/swiper-bundle.css'
export default {
name: 'AwesomeSwiper',
components: {
Swiper,
SwiperSlide,
},
data() {
return {
gallery: [
{ id: 1, src: 'https://source.unsplash.com/random/500x500?sig=1' },
{ id: 2, src: 'https://source.unsplash.com/random/500x500?sig=2' },
{ id: 3, src: 'https://source.unsplash.com/random/500x500?sig=3' },
],
swiperOptions: {
slidesPerView: 1,
spaceBetween: 30,
lazy: false,
effect: 'fade',
pagination: {
el: '.swiper-pagination',
type: 'progressbar',
},
navigation: {
disabledClass: '.nice-meme',
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
},
}
},
}
</script>
<style scoped>
.swiper {
width: 500px;
margin: 0 auto;
}
</style>
The result looks great so far

Related

Why does vue.js not work inside html files?

I wanted to add Vue.js to my Spring Boot application. Even though everything seem to build fine, I cannot make vue component work.
Here is my simple component, MenuBar.vue:
<template>
<div>
Menu
</div>
</template>
<script>
export default {
name: "MenuBar"
}
</script>
And here is HTML which should be using it:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Dashboard</title>
</head>
<body>
<div id="vueApp">
<menu-bar></menu-bar>
</div>
<form th:action="#{/logout}" method="post">
<div><input type="submit" value="Log out"/></div>
</form>
</body>
</html>
Configuration files index.js:
import Vue from "vue";
import App from './App.vue'
Vue.config.devtools = true;
new Vue({
el: '#app',
template: '<App/>',
components: {App}
});
new Vue({
el: '#vueApp'
})
components.js:
import Vue from 'vue';
import MenuBar from "./components/MenuBar";
Vue.component('menu-bar', MenuBar);
And webpack config file:
// webpack.config.js
const {VueLoaderPlugin} = require('vue-loader');
const path = require('path');
module.exports = {
mode: 'development',
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader'
},
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
]
}
]
},
entry: {
main: path.resolve(__dirname, './src/index.js')
},
resolve: {
extensions: ['.vue', '.js'],
alias: {
'components': path.resolve(__dirname, './src/components/')
}
},
plugins: [
// make sure to include the plugin for the magic
new VueLoaderPlugin()
],
devServer: {
hot: false,
liveReload: true,
proxy: {
"*": {
target: 'http://localhost:8080',
ignorePath: false,
changeOrigin: false,
secure: false
}
},
port: 8081,
host: "0.0.0.0"
},
output: {
publicPath: '/dist/',
path: path.resolve(__dirname, './src/main/resources/static/dist')
}
}
When I build npm and run application page contains element <menu-bar></menu-bar> but does not load its content. What could be an issue here?
The problem is that you add the component inside of <div id="vueApp"> at:
<div id="vueApp">
<menu-bar></menu-bar>
</div>
In this case, your app renders inside of this <div id="vueApp"> tag. Everything you write inside of this tag at your html file, will be overwritten.
You have another file named App.vue. You should add your MenuBar.vue component to this main component and it should show.
EDIT: Easiest attempt to get your component to work
This ist the main.js:
import { createApp } from 'vue'
import App from './App.vue'
// Create app
const app = createApp(App);
// Import component
import MenuBar from "./components/MenuBar";
// Use MenuBar
app.component('MenuBar', MenuBar);
// Mount app
app.mount('#app')
This is the App.vue:
<template>
<div>
<MenuBar></MenuBar>
Body
</div>
</template>
<script>
export default {
name: 'App',
}
</script>
This is the MenuBar.vue:
<template>
<div>
Menu
</div>
</template>
<script>
export default {
name: "MenuBar"
}
</script>
As we have a slight different approach I will also give you the package.json, so you can just hit npm install and it should implement all the (few) packages includet in this app:
{
"name": "q68966956",
"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": "^3.0.0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/compiler-sfc": "^3.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
It looks like you are in a early stage with your project, so maybe you can start with a stable base from that code. Let me know, if it helped you.

what is this configuration error with Vue.js eslint

I am newer on vueJs. I try this basic code in my vue to modify datas of a component in a vue:
<template>
<div>
<h1> {{ message }}
<h2> Hello {{ firstname }} {{ lastname }} de {{ from }} ! </h2>
<label> Firstname : <input type="text" v-model="person.firstname" /> </label>
<label> Lastname : <input type="text" v-model="person.lastname" /> </label>
<label> Message : <input type="text" v-model="message" /> </label>
</div>
</template>
<script>
export default {
data () {
person: {
firstname: 'John',
lastname: 'Doe'
},
message: 'Welcome!'
}
}
</script>
I get this error:
Failed to compile.
./src/components/Hello.vue?vue&type=script&lang=js& (./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Hello.vue?vue&type=script&lang=js&)
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: C:\Users\1900780\Documents\Afpa\Ressources\PHP\vueJs1\myproject\src\components\Hello.vue: Unexpected token, expected ";" (16:16)
14 | person: {
15 | firstname: 'John',
> 16 | lastname: 'Doe'
| ^
17 | },
18 | message: 'Welcome!'
19 | }
at Object.raise (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:7013:17)
at Object.unexpected (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:8384:16)
at Object.semicolon (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:8366:40)
at Object.parseExpressionStatement (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:11193:10)
at Object.parseStatementContent (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:10792:19)
at Object.parseStatement (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:10658:17)
at Object.parseLabeledStatement (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:11185:22)
at Object.parseStatementContent (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:10790:19)
at Object.parseStatement (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:10658:17)
at Object.parseBlockOrModuleBlockBody (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:11234:25)
at Object.parseBlockBody (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:11221:10)
at Object.parseBlock (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:11205:10)
at Object.parseStatementContent (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:10734:21)
at Object.parseStatement (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:10658:17)
at Object.parseLabeledStatement (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:11185:22)
at Object.parseStatementContent (C:\Users\...\vueJs1\myproject\node_modules\#babel\parser\lib\index.js:10790:19)
I use #vue/cli 4.1.2 and webpack.
My package.json:
{
"name": "myproject",
"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.4.4",
"vue": "^2.6.10"
},
"devDependencies": {
"#vue/cli-plugin-babel": "^4.1.0",
"#vue/cli-plugin-eslint": "^4.1.0",
"#vue/cli-service": "^4.1.0",
"babel-eslint": "^10.0.3",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"vue-template-compiler": "^2.6.10"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint",
"ecmaVersion": 6
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
My code seems to be correct. I don't understand this error. Is there a config to do with babel parser and where is the config file ?
I added an eccmaversion in the package.json file configuration, but it does not seems to work. Any help would be appreciated.
Houps! i just forgot the return statement:
export default {
data () {
return {
person: {
firstname: 'John',
lastname: 'Doe'
},
message: 'Welcome!'
}
}
}

Why is lodash not working when I import it in Vue.js

I created a fresh new install of vue.js using "vue create todo --default" command. After that I installed lodash too with this command "npm i --save lodash". I can see it in my package.json on the "dependencies" object. The problem is that when I import it on my main.js and use the lodash functions, it is showing the error "_ is not defined". So I tried importing it inside the App.vue. The error "_ is not defined" was removed but it is not working.
Here are the code inside the App.vue, main.js, and package.json
main.js
import Vue from 'vue'
import App from './App.vue'
import "bootstrap/dist/css/bootstrap.min.css";
import "jquery/dist/jquery";
import "bootstrap/dist/js/bootstrap.min";
import _ from "lodash";
Vue.prototype._ = _;
Vue.config.productionTip = false
new Vue({
render: h => h(App),
}).$mount('#app')
App.vue
<template>
<div id="app">
<h4 class="bg-primary text-white text-center p-2">
{{name}}'s' To Do List
</h4>
<div class="container-fluid p-4">
<div class="row">
<div class="col font-weight-bold">Task</div>
<div class="col-2 font-weight-bold">Done</div>
</div>
<div class="row" v-for="t in completedtask" v-bind:key="t.action">
<div class="col">{{t.action}}</div>
<div class="col-2">
<input type="checkbox" v-model="t.done" class="form-check-input">
{{t.done}}
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data(){
return{
name: "Welly",
tasks: [{
action: "Buy Flowers",
done: false
},
{
action: "Get Shoes",
done: false
},
{
action: "Collect Tickets",
done: true
},
{
action: "Call Joe",
done: false
}
]
};
},
computed: {
hidecompletedtask(){
return _.map(this.tasks,(val)=>{
return !val.done;
});
}
}
}
</script>
<style>
</style>
package.json
{
"name": "todo",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"bootstrap": "^4.4.1",
"core-js": "^3.4.4",
"jquery": "^3.4.1",
"lodash": "^4.17.15",
"popper.js": "^1.16.1",
"vue": "^2.6.10"
},
"devDependencies": {
"#vue/cli-plugin-babel": "^4.1.0",
"#vue/cli-plugin-eslint": "^4.1.0",
"#vue/cli-service": "^4.1.0",
"babel-eslint": "^10.0.3",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"vue-template-compiler": "^2.6.10"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
You'll still need to access the prototype via the this context, like this._.map().
computed: {
hidecompletedtask() {
return this._.map(this.tasks, (val) => {
return !val.done;
});
}
}
Reference: Adding Instance Properties.
Alternatively, you could extend the global window object. Put the following line in your main.js (or some booting file).
window._ = require('lodash');
Somewhere else where you need the library:
computed: {
hidecompletedtask() {
// The underscore (_) character now refers to the `window._ object`
// so you can drop the `this`.
return _.map(this.tasks, (val) => {
return !val.done;
});
}
}
You can also use vue-lodash package -- Follow these steps:
npm install --save vue-lodash
in main.js -- import VueLodash from 'vue-lodash'
in main.js after import -- Vue.use(VueLodash)
Usage:
Vue._.random(20);
this._.random(20);
-------- OR ------------
In your main.js add this line of code:
window._ = require('lodash');
That way it will work without Vue or this:
Just do -- _.map()
You can import lodash in your main.js file by javascript window object like this:
window._ = require('lodash');
Then use it anywhere in your projet like this:
var original = [
{ label: 'private', value: 'private#johndoe.com' },
{ label: 'work', value: 'work#johndoe.com' }
];
var update = [
{ label: 'private', value: 'me#johndoe.com' },
{ label: 'school', value: 'schol#johndoe.com' }
];
var result = _.unionBy(update, original);
var sortedresult = _map(_.sortBy(result, 'label'));
console.log(sortedresult);
I just use lodash unionBy and sortBy method for example.

Why does Vue convert my single quotes to double quotes in my background-image url?

Every post I've found on this topic referts to using Vetur or Prettier. I'm using neither. This is a basic Vue CLI install. The only thing I've added is sass-loader. I've added my package.json to the bottom of the post to confirm what I'm actually using.
<template>
<div class="hero-section" :style="{ backgroundImage: 'url(' + currentBgImage + ')' }">
<i class="fa fa-chevron-left" #click="previousImage()"></i>
<i class="fa fa-chevron-right" #click="nextImage()"></i>
</div>
</template>
<script>
export default {
name: 'HeroSlider',
props: {
imageArray: Array
},
data() {
return {
selectedImage: 0,
};
},
computed: {
currentBgImage() {
let array = this.imageArray;
let result = array[this.selectedImage].image;
return result;
}
},
The result is:
<div class="hero-section" style="background-image:url("/src/assets/image_1.jpg");">
<i class="fa fa-chevron-left"></i>
<i class="fa fa-chevron-right"></i>
</div>
I've also tried including the quotes in the computed property's value and in the html but the result was the same:
:style="{ backgroundImage: 'url(\'' + currentBgImage + '\')'
Now, something curious happened as I copied this HTML from my inspection window. When I pasted it here it initially pasted like this with " instead of ". Could that be an indicator of what's going wrong?
<div class="hero-section" style="background-image: url("/src/assets/image_1.jpg");">
<i class="fa fa-chevron-left"></i>
<i class="fa fa-chevron-right"></i>
</div>
package.json
{
"name": "heroslider",
"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.3.2",
"vue": "^2.6.10"
},
"devDependencies": {
"#vue/cli-plugin-babel": "^4.0.0",
"#vue/cli-plugin-eslint": "^4.0.0",
"#vue/cli-service": "^4.0.0",
"babel-eslint": "^10.0.3",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"node-sass": "^4.13.0",
"sass-loader": "^8.0.0",
"vue-template-compiler": "^2.6.10"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {
"no-console": "off"
},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
Why does Vue convert my single quotes to double quotes in my background-image url?
It doesn't.
See the following example, which isn't using any libraries at all:
const el = document.getElementById('div')
el.style.backgroundImage = 'url(https://vuejs.org/images/logo.png)'
console.log(el.style.backgroundImage)
console.log(el.outerHTML)
#div {
height: 100px;
width: 100px;
}
<div id="div"></div>
Notice that the console logging has " characters around the URL even though they didn't appear in the original value. Those are encoded to " within the HTML, which is correct.
The browser is normalizing the value. It shouldn't make any difference to the URL that is requested from the server. If your image isn't loading the quotes are not the problem. That should be evident by checking the URL being used to load the image in the Network tab of your browser's developer tools.

Component not registered properly, can't compile new files

I just added a simple component called AddScan to a v-dialog however I get this in console:
[Vue warn]: Unknown custom element: <AddScan> - did you register the component correctly?
For recursive components, make sure to provide the "name" option.
Also when I edit the file and save it vue-cli is not compiling it but when I edit another component and save the changes it compiles but gives me this error:
warning in ./src/views/ScanResults.vue?vue&type=script&lang=js&
"export 'AddScan' was not found in '#/components/scan'
This is really the first time I have this problem I have no idea what's wrong.
I'm on Vue 2.6.10 and Vuetify 2.1.7.
ScanResults.vue(parent):
<template>
<v-layout row>
<v-flex row class="justify-space-between ma-5 ">
<div>
<v-dialog v-model="dialog" width="500">
<template v-slot:activator="{ on }">
<v-btn v-on="on" class="ma-2 lowerCase" color="#E0E0E0">
Ajouter un scan
</v-btn>
</template>
<AddScan :items="items"></AddScan>
</v-dialog>
</div>
</v-flex>
<v-flex v-if="items.length < 2">
<ScanGrid :items="items"></ScanGrid>
</v-flex>
</v-layout>
</template>
<script>
import { mapGetters } from "vuex";
import { ScanGrid } from "#/components/scan";
import { AddScan } from "#/components/scan";
export default {
name: "ScanResults",
components: {
ScanGrid,
AddScan
},
...
AddScan.vue(child):
<template>
<v-card>
<v-list>
<v-list-item v-for="(item, i) in items" :key="i">
<v-list-item-content>
<v-list-item-title v-text="item.StorageName"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-card>
</template>
<script>
import { mapGetters } from "vuex";
export default {
name: "AddScan",
computed: {
...mapGetters(["getIsDarkMode", "getPhysicalInventoryBatch"])
},
async created() {
try {
await this.$store.dispatch("loadPhysicalInventoryBatch");
const items = this.$store.getters.getPhysicalInventoryBatch;
this.$emit("update", items);
} catch (e) {
console.error(e);
}
},
data: () => ({
items: [],
dialog: false
})
};
</script>
package.json:
{
"name": "",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 8084",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint",
"lint:fix": "vue-cli-service lint --fix"
},
"dependencies": {
"#fortawesome/fontawesome-svg-core": "^1.2.25",
"#fortawesome/free-solid-svg-icons": "^5.11.2",
"#fortawesome/vue-fontawesome": "^0.1.7",
"axios": "^0.19.0",
"core-js": "^3.3.5",
"material-design-icons-iconfont": "^5.0.1",
"moment": "^2.24.0",
"qrcode": "^1.4.2",
"register-service-worker": "^1.6.2",
"vue": "^2.6.10",
"vue-moment": "^4.0.0",
"vue-mugen-scroll": "^0.2.6",
"vue-promised": "^1.2.1",
"vue-router": "^3.1.3",
"vuetify": "^2.1.7",
"vuetify-dialog": "^0.3.8",
"vuex": "^3.0.1",
"vuex-i18n": "^1.13.1",
"vuex-persistedstate": "^2.6.0"
},
"devDependencies": {
"#fortawesome/fontawesome-free": "^5.11.2",
"#vue/cli-plugin-babel": "^4.0.5",
"#vue/cli-plugin-eslint": "^4.0.5",
"#vue/cli-plugin-pwa": "^4.0.5",
"#vue/cli-plugin-unit-jest": "^4.0.5",
"#vue/cli-service": "^4.0.5",
"#vue/eslint-config-prettier": "^4.0.1",
"#vue/test-utils": "1.0.0-beta.29",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.3",
"babel-jest": "^23.6.0",
"compression-webpack-plugin": "^3.0.0",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.2.3",
"lerna": "^3.18.3",
"sass": "^1.23.1",
"sass-loader": "^7.3.1",
"vue-template-compiler": "^2.5.21"
}
}
vue.config.js:
const CompressionPlugin = require("compression-webpack-plugin");
const path = require("path");
module.exports = {
outputDir: path.resolve(__dirname, "../PmpTeamMateDeploy/Pmp.Web.Inventory"),
configureWebpack: {
plugins: [new CompressionPlugin()],
devtool: "source-map"
},
css: {
loaderOptions: {
sass: {
data: `
#import "#/assets/style/style.scss";
`
}
}
},
pwa: {
workboxPluginMode: "InjectManifest",
workboxOptions: {
swSrc: "src/service-worker.js",
exclude: [/\.map$/, /manifest\.json$/]
},
themeColor: "#78a22e"
},
chainWebpack: config => {
["vue-modules", "vue", "normal-modules", "normal"].forEach(match => {
config.module
.rule("scss")
.oneOf(match)
.use("sass-loader")
.tap(opt =>
Object.assign(opt, { data: `#import '~#/assets/style/style.scss';` })
);
});
}
};
UPDATE: In my parent component in components section I added AddScan: () => import("#/components/scan") and that got rid of the compile errors I was getting however I still can't compile when I save the AddScan file.
I also update vue-cli and all plugins and dependencies from 3.12.1 to 4.0.5, core-js from 2.6.10 to 3.3.5, sass-loader from 7.3.1 to 8.0.0 but reverted to 7.3.1 because it threw me 104 errors on compile for some reason, as well as Node from 10.something to 12.13.0.
UPDATE 2: Basically the problem seems that vue refuses to compile new files. The old ones compile fine for some reason. I tried loading an old version of the branch with older packages versions, just npm install, still won't compile new files.
Well I feel like an unbelievable idiot but here we go: The component was in components/scan but since it was a parent component and I'm calling it in a view I completely forgot to do import/export it in my index.js file in the scan folder.
components/scan/index.js:
import ScanGrid from "./ScanGrid";
import ScanAdd from "./ScanAdd";
export { ScanGrid };
export { ScanAdd };