@orpha
To use an NPM package with Laravel Vite, you can follow these steps:
1
|
npm install package-name |
1 2 3 4 5 6 7 8 9 10 11 |
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'lodash-es': 'lodash'
}
}
});
|
1 2 3 4 5 6 7 |
import _ from 'lodash';
export default {
created() {
console.log(_.sortBy([3, 1, 2])); // Output: [1, 2, 3]
}
}
|
By following these steps, you can easily use NPM packages with Laravel Vite in your projects.