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

Vite and stimulus invalid unicode #51

Open
JSlomian opened this issue Oct 25, 2024 · 0 comments
Open

Vite and stimulus invalid unicode #51

JSlomian opened this issue Oct 25, 2024 · 0 comments

Comments

@JSlomian
Copy link

So I added vite from pentatrion after updating symfony from 5.4 to 6.4 to modernize company application. However stimulus keeps being added to alot of files and it causes errors if the file starts with u because it inserts \u.

This is what's being inserted when running vite

if (import.meta.hot) {
  import.meta.hot.accept(newModule => {
    if (!window.$$stimulusApp$$) {
      console.warn('Stimulus app not available. Are you creating app with startStimulusApp() ?');
      import.meta.hot.invalidate();
    } else {
      window.$$stimulusApp$$.register('vendor\symfony\ux-vue\assets\dist\render', newModule.default);
    }
  })
}

This is my vite.config.js

import {defineConfig} from "vite";
import symfonyPlugin from 'vite-plugin-symfony';
import { viteStaticCopy} from "vite-plugin-static-copy";
import vuePlugin from "@vitejs/plugin-vue";
import * as path from "node:path";
import vueDevTools from "vite-plugin-vue-devtools"

const isBuild = process.argv.includes('build');

export default defineConfig({
  root: '.',
  base: isBuild ? '/sklep/build' : '/build',
  assetsInclude: ['**/*.doc'],
  resolve: {
    extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.scss', '.css', '.vue'],
    alias: {
      '@': path.resolve(__dirname, './assets/'),
      '~': path.resolve(__dirname, 'node_modules')
    }
  },
  plugins: [
    vueDevTools(),
    vuePlugin(),
    symfonyPlugin({
      refresh: ["templates/**/*.twig"],
      stimulus: true
    }),
    viteStaticCopy({
      targets: [
        {
          src: './assets/documents/*.{doc,docx}',
          dest: 'assets/documents'
        }
      ]
    })
  ],
  build: {
    assetsInlineLimit: 0,
    manifest: true,
    rollupOptions: {
      input: {
        app: "./assets/app.js",
        categoryViewCart: "./assets/categoryViewCart.js",
        singleProduct: "./assets/singleProduct.js",
        newProductsCart: "./assets/newProductsCart.js",
        shopRegister: "./assets/shopRegister.js",
        passwordEyeToggle: "./assets/passwordEyeToggle.js",
        userProfile: "./assets/userProfile.js"
      },
    },
    outDir: 'public/build',
  },
});

the part in app.js

import { registerVueControllerComponents } from "vite-plugin-symfony/stimulus/helpers/vue"
import { startStimulusApp, registerControllers } from "vite-plugin-symfony/stimulus/helpers"


registerVueControllerComponents(import.meta.glob('./vue/controllers/**/*.vue'))

const app = startStimulusApp();
registerControllers(
  app,
  import.meta.glob(
    "./controllers/*_controller.js",
    {
      query: "?stimulus",
      eager: true,
    },
  ),
);

I don't remember this but must've been from recipes

{
    "controllers": {
        "@symfony/ux-vue": {
            "vue": {
                "enabled": true,
                "fetch": "eager"
            }
        }
    },
    "entrypoints": []
}

My vue components are not displayed as well using vue_component I have to manually createApp and mount it and disabling stimulus breaks everythings. My office pc is running windows.

If this is not the right place I'm sorry and let me know where I should paste it instead. Thanks!

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

1 participant