Search code examples
javascriptwebpackvisual-studio-codebabeljstokenize

How to turn off tokenization of specific files with VSCode


I am writing javascript with VSCode. The written code is transpiled with babel and bundled with webpack to generate a file called dist.js. This file is transpiled in production mode, so it is not readable and does not require tokenization. However, every time I open this file (a huge file that doesn't get caught up by large file optimization), I wait for a few seconds because of tokenization. How can I turn off tokenization for this file?

What I tried

When I set webpack to save the bundle result file with the name dist.txt, tokenization could be turned off, but for some reason it was no longer in production mode.

I was able to apply large file optimization by increasing the file size with useless text, but I would like to solve it in a better way if possible.


Solution

  • To the best of my knowledge, there aren't any file-specific settings for the moment

    However, you can lower the tokenization threshold ( which is by default very high, as you noticed ) to a smaller value:

    // in your settings, e.g. .vscode/settings.json
    
    // lines longer than 1000 chars are already pretty rare in non-production code
    "editor.maxTokenizationLineLength": 1000
    

    This will result in a substantial speed-up.