I am using vuetify in Laravel. I had created a laravel 8 project with vue version 2 using laravel/ui package. Everything seems to work fine and all the components of vuetify rendered properly. But when I try to change a variable in my variables.scss in resources/sass/variables.scss, It doesn't seems to work accordingly. e.g: when i want to change the default border radius from 4px to let say 10px using $border-radius-root: 6px; as mentioned in vuetify documentation. It doesn't work. Below is my webpack.mix.js
const mix = require("laravel-mix");
require("vuetifyjs-mix-extension");
mix.js("resources/js/app.js", "public/js")
.vuetify()
.vue({ version: 2 })
.sass("resources/sass/app.scss", "public/css");
And my package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"axios": "^0.24",
"deepmerge": "^4.2.2",
"laravel-mix": "^6.0.39",
"resolve-url-loader": "^4.0.0",
"sass": "^1.43.4",
"sass-loader": "^12.3.0",
"vue": "^2.6.14",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.6.14",
"vuetifyjs-mix-extension": "^0.0.20"
},
"dependencies": {
"#mdi/font": "^6.4.95",
"#mdi/js": "^6.4.95",
"material-design-icons-iconfont": "^6.1.1",
"vue-router": "^3.5.3",
"vuetify": "^2.5.14",
"vuetify-loader": "^1.7.3",
"vuex": "^3.6.2"
}
}
my app.scss file content
// Fonts
#import url("https://fonts.googleapis.com/css?family=Nunito");
// Variables
#import url("variables.scss");
my variables.scss content
$border-radius-root: 14px !important; // this portion didn't work.
and the vuetify.js plugin file content
import Vue from "vue";
import Vuetify from "vuetify";
// To add vuetify css file
import "vuetify/dist/vuetify.min.css";
import colors from "vuetify/lib/util/colors";
import "material-design-icons-iconfont/dist/material-design-icons.css"; // Ensure you are using css-loader
import "#mdi/font/css/materialdesignicons.css"; // Ensure you are using css-loader
Vue.use(Vuetify);
const opts = {
icons: {
iconfont: "mdi" || "mdiSvg" || "md",
},
theme: {
themes: {
light: {
primary: "#26695C", // #E53935
secondary: colors.indigo.accent4, // #FFCDD2
accent: "#BA895D", // #3F51B5
black: "#000000",
primaryLight: "#E9F0EE",
},
},
},
};
// primary: "#DB6015", // #E53935
// secondary: colors.indigo.accent4, // #FFCDD2
// accent: "#005677" // #3F51B5
export default new Vuetify(opts);
and I am using the vuetifyjs-mix-extension in my laravel mix configuration.
It's a little difficult with the approach you are trying to use for. I can suggest the following one:
vuetify.js (imported in the app)
import Vue from "vue";
import Vuetify from "vuetify/lib/framework";
import es from "vuetify/lib/locale/es";
Vue.use(Vuetify);
export default new Vuetify({
theme: {
options: {
customProperties: true,
},
// More props here...
},
// More stuffs here...
});
webpack.mix.js
const mix = require("laravel-mix");
require("vuetifyjs-mix-extension");
mix
.js("resources/js/app.js", "public/js")
.vue()
// here's where the magic happens.
.vuetify("vuetify-loader", { extract: "[name].csss" })
.version()
.disableNotifications();
Now that you have these settings. Ensure you...
Have the following file: resources/sass/variables.scss
If you have custom fonts, it's preferable that you import them via html rather than here, that's more efficient.
You will be able to see the updates on your code.
Side note: There are my plugins versions:
{
//...
"dependencies": {
//...,
"vue": "^2.6.12",
"vue-router": "^3.5.1",
"vuetify": "^2.5.3"
},
"devDependencies": {
// ...,
"deepmerge": "^4.2.2",
"laravel-mix": "^6.0.24",
"postcss": "^8.2.12",
"prettier": "^2.2.1",
"sass": "1.32.6",
"sass-loader": "^11.0.1",
"vue-cli-plugin-vuetify": "^2.3.1",
"vue-loader": "^15.9.6",
"vue-template-compiler": "^2.6.12",
"vuetify-loader": "^1.7.2",
"vuetifyjs-mix-extension": "^0.0.20"
}
}
Related
For some strange reason, whenever I run npm run dev, each time, my /public/js/app.js file seems to gain a few MB, regardless of not changing any code.
webpack.mix.js
mix.js('resources/js/app.js', 'public/js')
.vue()
.postCss('resources/css/app.css', 'public/css', [
require('postcss-import'),
require('tailwindcss'),
])
.webpackConfig(require('./webpack.config'));
if (mix.inProduction()) {
mix.version();
}
if (!mix.inProduction()) {
mix.bundleAnalyzer({
analyzerMode: 'static'
});
}
webpack.config.js
const path = require('path');
module.exports = {
resolve: {
alias: {
'#': path.resolve('resources/js'),
},
},
};
app.js
require('./bootstrap');
import { createApp, h } from 'vue';
import { createInertiaApp } from '#inertiajs/inertia-vue3';
import { InertiaProgress } from '#inertiajs/progress';
const appName = window.document.getElementsByTagName('title')[0]?.innerText
|| 'Laravel';
createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) => require(`./Pages/${name}.vue`),
setup({ el, app, props, plugin }) {
return createApp({ render: () => h(app, props) })
.use(plugin)
.mixin({ methods: { route } })
.mount(el);
},
});
InertiaProgress.init({ color: '#4B5563' });
The problem seems to be the .vue() in the webpack file, which, when run without, reduces the app.js size down to 700kb. But, of course, without it, I get:
ERROR in ./resources/js/Pages/Dashboard.vue 1:0 Module parse failed:
Unexpected token (1:0) You may need an appropriate loader to handle
this file type. Currently, no loaders are configured to process this
file. See https://webpack.js.org/concepts#loaders
package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"#inertiajs/inertia": "^0.10.0",
"#inertiajs/inertia-vue3": "^0.5.1",
"#inertiajs/progress": "^0.2.6",
"#tailwindcss/forms": "^0.2.1",
"#vue/compiler-sfc": "^3.0.5",
"autoprefixer": "^10.2.4",
"axios": "^0.21",
"laravel-mix": "^6.0.6",
"laravel-mix-bundle-analyzer": "^1.0.5",
"lodash": "^4.17.19",
"postcss": "^8.2.13",
"postcss-import": "^14.0.1",
"tailwindcss": "^2.2.7",
"vue": "^3.0.5",
"vue-loader": "^16.1.2"
},
"dependencies": {
"#headlessui/vue": "^1.4.0",
"#heroicons/vue": "^1.0.4"
}
}
Please can someone point me in the right direction?
I use Vuetify loader in my Laravel project but compilation doesn't work.
Laravel : 8.46
Vue : 2.6.14
Vuetify : 2.5.3
This is my package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"axios": "^0.21",
"deepmerge": "^4.2.2",
"laravel-mix": "^6.0.6",
"path": "^0.12.7",
"postcss": "^8.1.14",
"sass": "^1.34.1",
"sass-loader": "^12.1.0",
"vue": "^2.6.14",
"vue-loader": "^15.9.5",
"vue-template-compiler": "^2.6.14",
"vuetify": "^2.5.3",
"vuetify-loader": "^1.7.2"
}
}
My webpack.mix.js
const mix = require('laravel-mix');
const path = require('path');
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin')
mix.webpackConfig({
resolve: {
alias: {
'#': path.resolve(__dirname, 'resources/js/')
}
},
module: {
rules: [
{
test: /\.s(c|a)ss$/,
use: [
"sass-loader",
'vue-style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
implementation: require('sass'),
sassOptions: {
indentedSyntax: true
},
},
},
],
},
],
},
plugins: [
new VuetifyLoaderPlugin()
],
});
mix.js('resources/js/app.js', 'public/js')
.vue()
//.extract(['vue'])
.postCss('resources/css/app.css', 'public/css', [
//
]);
if (mix.inProduction()) {
mix.version();
}
My entry :
require('./bootstrap');
import Vue from 'vue'
import vuetify from '#/plugins/vuetify'
new Vue({
vuetify,
}).$mount('#app')
And my vuetify plugin :
import Vue from 'vue'
import Vuetify from 'vuetify/lib'
Vue.use(Vuetify)
const opts = {}
export default new Vuetify(opts)
But when I run yarn dev, I have an error :
...
ERROR in ./node_modules/vuetify/src/styles/main.sass (./node_modules/css-loader/dist/cjs.js??clonedRuleSet-15[0].rules[0].use[1]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-15[0].rules[0].use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-15[0].rules[0].use[3]!./node_modules/sass-loader/dist/cjs.js!./node_modules/vue-style-loader/index.js!./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-22[0].rules[0].use[3]!./node_modules/vuetify/src/styles/main.sass)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Expected newline.
╷
4 │ var content = require("!!../../../css-loader/dist/cjs.js!../../../sass-loader/dist/cjs.js??clonedRuleSet-22[0].rules[0].use[3]!./main.sass");
│ ^
╵
node_modules/vuetify/src/styles/main.sass 4:141 root stylesheet
webpack compiled with 95 errors
I follow Vuetify documentation and Mix documentation.
i'm trying to install this package https://github.com/shwilliam/vue-scrollin to my laravel + vue project. after compiling with laravel mix, the following error appeared:
Module not found: Error: Can't resolve 'timers' in
'\node_modules\vue-scrollin\dist'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules
by default. This is no longer the case. Verify if you need this module
and configure a polyfill for it. If you want to include a polyfill,
you need to:
- add a fallback 'resolve.fallback: { "timers": require.resolve("timers-browserify") }'
- install 'timers-browserify' If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "timers": false }
I followed the given instructions but it gives me the same errors.
webpack.mix.js
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js').vue()
.sass('resources/css/app.scss', 'public/css/app.css')
.postCss('resources/css/app.css', 'public/css', [
//
])
.webpackConfig(require('./webpack.config'));
webpack.config.js
module.exports = {
resolve: {
fallback: { "timers": require.resolve("timers") }
},
};
package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"#fortawesome/fontawesome-free": "^5.15.3",
"#fortawesome/fontawesome-svg-core": "^1.2.35",
"#fortawesome/free-regular-svg-icons": "^5.15.3",
"#fortawesome/free-solid-svg-icons": "^5.15.3",
"#fortawesome/vue-fontawesome": "^3.0.0-3",
"#vue/compiler-sfc": "^3.0.7",
"axios": "^0.21",
"bulma": "^0.9.2",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"particles.vue3": "^1.3.1",
"postcss": "^8.1.14",
"resolve-url-loader": "^3.1.2",
"sass": "^1.32.8",
"sass-loader": "^10.1.1",
"vue": "^3.0.5",
"vue-loader": "^16.1.2",
"vue-router": "^4.0.5",
"vue-scrollin": "^0.1.2",
"timers-browserify": "^2.0.12"
}
}
You almost got it. webpack.config.js should be:
module.exports = {
resolve: {
fallback: { "timers": require.resolve('timers-browserify') }
},
};
Just change the package in the require.resolve() to what the warning suggests.
For anyone who comes here with a polyfills-problem or about to migrate from webpack 4 to 5, here's the PR with a list of removed polyfills
Currently learning and using VueRouter for the first time in laravel. There are no errors but when I try to run the page it just appears blank. I've gone through the code and the tutorial i have been following multiple times but cannot see what is going wrong.
This is my app.js
require("./bootstrap");
window.Vue = require('vue');
import Vue from 'vue'
import VueRouter from "vue-router";
import routes from "./routes";
Vue.use(VueRouter);
const app = new Vue({
el: "#app",
router: new VueRouter(routes),
});
This is my routes.js
import Home from './components/Home';
export default{
mode: 'history',
routes: [
{
path: '/',
component: Home
}
]
}
my Home.vue
<template>
<div>HELLO WORLD, NICE VUE</div>
</template>
<script>
export default {}
</script>
my welcome.blade.php
#extends('layouts.app')
#section('content')
<router-view></router-view>
#endsection
my package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"axios": "^0.21",
"jquery": "^3.2",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"resolve-url-loader": "^2.3.1",
"sass": "^1.20.1",
"sass-loader": "^8.0.0",
"vue": "^2.5.17",
"vue-loader": "^15.9.6",
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"tailwindcss": "^2.0.3",
"vue-router": "^3.5.1"
}
}
I Have a problem when use CKEditor 5 for my project ( VILT stack )
I can describe the problem as follows :
Here is my vue file:
<template>
<app-layout>
<ckeditor :editor="editor" #blur="onEditorInput" v-model="editorData" :config="editorConfig"></ckeditor>
</app-layout>
</template>
<script>
import AppLayout from '#/Layouts/AppLayout'
import ClassicEditor from '#ckeditor/ckeditor5-build-classic';
export default {
components: {
AppLayout,
},
data() {
return {
editor: ClassicEditor,
editorData: '',
editorConfig: {
// The configuration of the editor.
}
}
},
methods: {
onEditorInput() {
console.log(this.editorData);
}
}
}
</script>
and here's the app.js :
require('./bootstrap');
// Import modules...
import Vue from 'vue';
import { App as InertiaApp, plugin as InertiaPlugin } from '#inertiajs/inertia-vue';
import PortalVue from 'portal-vue';
import CKEditor from '#ckeditor/ckeditor5-vue2';
Vue.mixin({ methods: { route } });
Vue.use(InertiaPlugin);
Vue.use(PortalVue);
Vue.use( CKEditor );
const app = document.getElementById('app');
new Vue({
render: (h) =>
h(InertiaApp, {
props: {
initialPage: JSON.parse(app.dataset.page),
resolveComponent: (name) => require(`./Pages/${name}`).default,
},
}),
}).$mount(app);
and here are the contents of the package.json file :
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"#inertiajs/inertia": "^0.8.2",
"#inertiajs/inertia-vue": "^0.5.4",
"#tailwindcss/forms": "^0.2.1",
"#tailwindcss/typography": "^0.3.0",
"autoprefixer": "^10.0.2",
"axios": "^0.21",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"portal-vue": "^2.1.7",
"postcss": "^8.1.14",
"postcss-import": "^12.0.1",
"tailwindcss": "^2.0.1",
"vue": "^2.5.17",
"vue-loader": "^15.9.6",
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"#ckeditor/ckeditor5-build-classic": "^25.0.0",
"#ckeditor/ckeditor5-vue2": "^1.0.5"
}
}
So you can see in the console it says h2 but it looks like a p tag and I don't like it, how do I make the text look like h2 when I select the h2 option?
i have tried reading the documentation ( Quick start ) but still haven't found the right solution
that's because you are using tailwindcss and it escapes H tags. You can add
#layer
base {
h1 {
#apply text-2xl;
}
h2 {
#apply text-xl;
}
}
to your resources->css->app.css file and you will make it work as normal.