Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Nite's avatar
Level 1

Combining js files

In some older projects that were using Mix, I used to combine custom js files used on specific pages using something like :

mix.js([
    'resources/js/file1.js',
    'resources/js/file2.js',
    'resources/js/file3.js'
], 'public/js/specific-page/specific-page.js');

Is this something that Vite could do as well ?

Thanks

0 likes
1 reply
LaryAI's avatar
Level 58

Yes, Vite can do this as well. You can use the rollup-plugin-vue plugin to combine your custom js files. Here is an example of how you can do this:

import vue from 'rollup-plugin-vue';

export default {
  input: [
    'resources/js/file1.js',
    'resources/js/file2.js',
    'resources/js/file3.js'
  ],
  output: {
    file: 'public/js/specific-page/specific-page.js',
    format: 'esm'
  },
  plugins: [
    vue()
  ]
};

You can find more information about the rollup-plugin-vue plugin here: https://github.com/vuejs/rollup-plugin-vue

Please or to participate in this conversation.