Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev compilation extremely slow (~200 seconds) #662

Closed
Cypaubr opened this issue Oct 28, 2019 · 3 comments
Closed

Dev compilation extremely slow (~200 seconds) #662

Cypaubr opened this issue Oct 28, 2019 · 3 comments

Comments

@Cypaubr
Copy link

Cypaubr commented Oct 28, 2019

When I compile my project, it takes a huge amount of time in dev --watch mode. The problem does not occur in production mode.

Here is my webpack.config.js:

var Encore = require('@symfony/webpack-encore');
const Terser = require('terser-webpack-plugin');

// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
if (!Encore.isRuntimeEnvironmentConfigured()) {
    Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}

Encore
    // directory where compiled assets will be stored
    .setOutputPath('public/build/')
    // public path used by the web server to access the output path
    .setPublicPath('/build')

    .addEntry('app', './assets/js/app.js')
    .addEntry('admin', './assets/js/admin.js')
    .addEntry('admin-login', './assets/js/admin-login.js')
    .addEntry('login', './assets/js/login.js')
    .addEntry('chat', './assets/js/chat.js')
    .addEntry('profile', './assets/js/profile.js')

    // images copy
    .copyFiles({
        from: './assets/img',
        to: 'img/[path][name].[ext]'
    })

    .splitEntryChunks()

    .enableSingleRuntimeChunk()

    .cleanupOutputBeforeBuild()
    .enableBuildNotifications()
    .enableSourceMaps(!Encore.isProduction())

    .enableVersioning(Encore.isProduction())

    // enabling @babel/preset-env polyfills
    .configureBabel(() => {}, {
        useBuiltIns: 'usage',
        corejs: 3
    })

    // enabling Sass/SCSS support
    .enableSassLoader()

    //enabling React
    .enableReactPreset()

    .enableIntegrityHashes(Encore.isProduction())

    //Terser Config
    .addPlugin(new Terser({
        parallel: true,
        sourceMap: !Encore.isProduction(),
        terserOptions: {
            mangle: Encore.isProduction()
        }

    }))
;

module.exports = Encore.getWebpackConfig();

Do you have any solution to speed up the compilation in dev mode?

@Lyrkan
Copy link
Collaborator

Lyrkan commented Oct 28, 2019

Hi @Cypaubr,

I'm closing this thread since we already have one about build performances: #476 (comment)

Some remarks regarding your webpack.config.js though:

@Lyrkan Lyrkan closed this as completed Oct 28, 2019
@Cypaubr
Copy link
Author

Cypaubr commented Oct 28, 2019

@Lyrkan I already tried these solutions, it changes nothing...

@Lyrkan
Copy link
Collaborator

Lyrkan commented Oct 28, 2019

Your webpack.config.js file is pretty basic apart from the extra terser-webpack-plugin instance (which should be removed anyway), so it's not really possible to know what's causing your issue without a repro.

You could try adding the ProfilingPlugin to your config and then inspecting the generated events file: https://webpack.js.org/plugins/profiling-plugin/

It will be really verbose but if a single thing takes a really long time you should be able to see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants