Search code examples
javascriptqtqt-creatorqtquick2

Qt Creator exclude JavaScript files from compilation process


I have a few JavaScript and HTML files inside the QT Quick Project that I want to exclude from the compilation process, but I want to have these files in the final executable.

When I build the project in release mode, for a few of the minified JavaScript files, QT is giving me errors, so I want to exclude these files from the build. These JS files are used from a web component running inside the QtWebEngine so it is ok if these are not compiled.


Solution

  • Obviously, you are utilizing Qt Quick Compiler with release build which compiles all .qml and .js in your resources. I assume you are using qmake build system because Qt Creator enables quick compiler for qmake based release builds by default but for CMake you need to manually enable it in CMakeLists.txt (at least for now).

    For qmake based build you find the answer from the Qt Quick Compiler doc:

    If you have .qml or .js files which should not be compiled but just bundled by the resource system, then you can omit them from the compilation by specifying the resources files that contain them in the QTQUICK_COMPILER_SKIPPED_RESOURCES variable in your project file, like below:

    QTQUICK_COMPILER_SKIPPED_RESOURCES += bundle_only.qrc