Just updated from webpack to vite (laravel 9.19).
var createContext = (ctx2) => {
ctx2 = Object.assign({
cwd: process.cwd(),
env: "development"
}, ctx2);
if (!ctx2.env) {
"development" = "development"; <----- THIS LINE
}
return ctx2;
};
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"@inertiajs/inertia": "^0.10.0",
"@inertiajs/inertia-vue3": "^0.5.1",
"@inertiajs/progress": "^0.2.6",
"@intlify/vite-plugin-vue-i18n": "^3.4.0",
"@intlify/vue-i18n-loader": "^4.2.0",
"@tailwindcss/aspect-ratio": "^0.4.0",
"@tailwindcss/forms": "^0.5.2",
"@tailwindcss/line-clamp": "^0.4.0",
"@tailwindcss/typography": "^0.5.2",
"@vitejs/plugin-vue": "^2.3.3",
"@vue/compiler-sfc": "^3.0.5",
"autoprefixer": "^10.4.7",
"axios": "^0.21",
"compression-webpack-plugin": "^9.2.0",
"laravel-echo": "^1.11.4",
"laravel-mix": "^6.0.6",
"laravel-vite-plugin": "^0.3.0",
"lodash": "^4.17.19",
"postcss": "^8.4.14",
"postcss-import": "^12.0.1",
"pusher-js": "^7.0.6",
"tailwindcss": "^3.1.4",
"vite": "^2.9.14",
"vue": "^3.0.5",
"vue-loader": "^16.1.2"
},
"dependencies": {
"@headlessui/vue": "^1.5.0",
"@heroicons/vue": "^1.0.6",
"dayjs": "^1.11.0",
"vue-i18n": "^9.1.9",
"vue3-charts": "^1.1.31"
}
}
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import vueI18n from '@intlify/vite-plugin-vue-i18n'
export default defineConfig({
plugins: [
laravel({
input: 'resources/js/app.js',
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
vueI18n({
// if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
// you need to set i18n resource including paths !
// include: path.resolve(__dirname, './resources/js/app.js')
})
],
});
import { createI18n } from '@intlify/vite-plugin-vue-i18n'
const i18n = createI18n({
locale: localStorage.getItem("lang"), // set locale
fallbackLocale: 'en', // set fallback locale
})
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(i18n)
.use(ZiggyVue, Ziggy)
.mount(el);
},
});