Minifying RequireJS Javascript codebase to a single file

前端 未结 1 1141
再見小時候
再見小時候 2021-02-02 10:41

I am new to RequireJS and maybe this is an already discussed issue but I could not find a clear answer or opinion about this.

I have an application working with RequireJ

相关标签:
1条回答
  • 2021-02-02 10:53

    What you want is the RequireJS Optimizer.

    The optimizer does the following (from the docs):

    • Combines related scripts together into build layers and minifies them via UglifyJS (the default) or Closure Compiler (an option when using Java).
    • Optimizes CSS by inlining CSS files referenced by @import and removing comments.

    Here's one article on the topic for further reference.

    Have a look also at r.js, the command line tool which includes the optimizer. Using r.js, you can generate an optimized build from an application file main.js with just:

    node r.js -o build.js
    

    where build.js is a requirejs config file containing your build profile (baseUrl, paths, etc.).

    0 讨论(0)
提交回复
热议问题