Поэтому я попробовал следующее в vite.config.js:
Код: Выделить всё
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import inject from '@rollup/plugin-inject'
// define & and jQuery on the global window object
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
inject({ // => that should be first under plugins array
$: 'jquery',
jQuery: 'jquery',
}),
vue(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})
Код: Выделить всё
import { createApp } from 'vue'
import App from './App.vue'
import $ from 'jquery';
window.$ = window.jQuery = $;
createApp(App).mount('#app')
Код: Выделить всё
[vite] warning: rollup-plugin-inject: failed to parse D:/vespagiri/src/components/Header.vue. Consider restricting the plugin to particular files via options.include
plugin: inject
File:D:/vespagiri/src/components/Header.vue
Подробнее здесь: https://stackoverflow.com/questions/780 ... -but-still
Мобильная версия