Answer the question
In order to leave comments, you need to log in
How to speed up Webpack build from 30 minutes to 5-10?
The working project is quite voluminous, it is written in Vue + TypeScript and is assembled by webpack in about 30-40 minutes. Accordingly, when switching branches, creating / deleting files, hotreload breaks and you have to wait again for half an hour.
Are there ways to hardware speed up builds? Tried to put on SSD, tried on a new computer with a powerful processor (i7-8700), tried on the old one (i5-4250M) - everywhere the result is the same. Are there any ways to reduce the build time by at least a third without editing the code?
In general, I would like to know what is the load during assembly - disk, processor, RAM, something else?
Answer the question
In order to leave comments, you need to log in
Found the solution by analyzing the build process. I noticed that some files that literally consist of one props are compiled in a minute. There were no libraries, styles were also only their own. The problem was TypeScript type checking - it and the compilation of the files happened on the same thread.
Here is the solution if you are using ts-loader:
Install the plugin
In webpack.config.js - register the plugin, add the transpileOnly: true option to the loader and add the plugin to plugins:
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = {
module: {
rules: [
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
transpileOnly: true
}
]
},
plugins: [
new ForkTsCheckerWebpackPlugin()
],
Unhealthy bullshit. No matter how big projects I took part in, I never saw such figures.
Made a build of the previous rather big project with one client entry point and one server entry point (React / Typescript) on i7-4770HQ - 1 minute 45 seconds.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question