Webpack compile time

I played a bit with Babylon on one project where I imported the whole min file as an individual script tag and worked like that. Compile my code with webpack, had 2 script files (babylon.min and my script.js) and everything worked nicely.

Now I wanted to start a new project but to use ES6 and integrate TS so I can have IntelliSense and autocomplete in my IDE.
But now I have a problem that the initial project, so without any custom code, just importing Engine and Scene takes around 30sec.

I know that is somewhat expectable since the whole game engine needs to be compiled. But my questions here is, is there some workaround, for example, while developing do something else, pull it someway different, and then for the production, it can compile fully.

I have a feeling this question doesn’t make much sense but I wanted to try.

My end goal is that I want to have IntelliSense like on the playground, but not to wait for 30seconds compile.

Thank you in advance.

Are you using webpack-dev-server or are you doing a whole webpack build every time?

You could also try adding this to your webpack config, which should split the output into two files - one for your code and one for babylon which hopefully needs to be rebuilt less often.

optimization: {
    splitChunks: {
        chunks: 'all',
    },
},

You probably want to use HtmlWebpackPlugin with that so it can automatically include the correct script tags.

3 Likes

Oh, i was using normal webpack build. tested it now with webpack-dev-server and both with and without chunks, its waaaay faster. Thank you very much!