Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS not working in Vue3 - Vite Project #146

Open
Uhasith opened this issue Feb 9, 2024 · 2 comments
Open

CSS not working in Vue3 - Vite Project #146

Uhasith opened this issue Feb 9, 2024 · 2 comments

Comments

@Uhasith
Copy link

Uhasith commented Feb 9, 2024

I did configure this on app.js and vite.config.js but CSS not working.

import VueEasyLightbox from "vue-easy-lightbox";

const meta = document.createElement("meta");
meta.name = "naive-ui-style";
document.head.appendChild(meta);

const appName = import.meta.env.APP_NAME || 'Laravel';

const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
    setup({ el, App, props, plugin }) {
        return createApp({ render: () => h(App, props) })
            .use(plugin)
            .use(naive)
            .use(ZiggyVue)
            .use(pinia)
            .use(i18nVue, {
                resolve: async (lang) => {
                    const langs = import.meta.glob("../../lang/*.json");
                    return await langs[`../../lang/${lang}.json`]();
                },
            })
            .use(VueApexCharts)
            .use(VueEasyLightbox)
            .mount(el);
    },
    progress: {
        color: '#4B5563',
    },
});
import laravel from "laravel-vite-plugin";
import vue from "@vitejs/plugin-vue";

export default defineConfig({
    plugins: [
        laravel({
            input: "resources/js/app.js",
            ssr: "resources/js/ssr.js",
            refresh: true,
        }),
        vue({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false,
                },
            },
        }),
    ],
    resolve: {
        alias: {
            "vue-easy-lightbox":
                "vue-easy-lightbox/dist/external-css/vue-easy-lightbox.esm.min.js",
        },
    },
    optimizeDeps: {
        exclude: ["js-big-decimal"],
    },
});
Screenshot 2024-02-09 at 09 58 45
@kodzop
Copy link

kodzop commented Feb 13, 2024

I have the same problem. Don't know how to fix it yet.

EDIT:
To fix it, remove the resolve.alias
'vue-easy-lightbox': 'vue-easy-lightbox/dist/external-css/vue-easy-lightbox.esm.min.js'
in vite.config.js, and add @import to your scss file
@import 'vue-easy-lightbox/dist/external-css/vue-easy-lightbox';

@XiongAmao
Copy link
Owner

I have the same problem. Don't know how to fix it yet.

EDIT: To fix it, remove the resolve.alias 'vue-easy-lightbox': 'vue-easy-lightbox/dist/external-css/vue-easy-lightbox.esm.min.js' in vite.config.js, and add @import to your scss file @import 'vue-easy-lightbox/dist/external-css/vue-easy-lightbox';

@Uhasith

If you are using external-css build, remove the resolve.alias 'vue-easy-lightbox': 'vue-easy-lightbox/dist/external-css/vue-easy-lightbox.esm.min.js' in vite.config.js.
And put this in main.js/app.js :

// for external-build
import vue-easy-lightbox from 'vue-easy-lightbox/external-css'

import 'vue-easy-lightbox/external-css/vue-easy-lightbox.css'

// or add @import in your style file 
// @import 'vue-easy-lightbox/dist/external-css/vue-easy-lightbox';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants