Uglify one JS file using requirejs optimizer

前端 未结 3 1139
自闭症患者
自闭症患者 2021-01-21 19:51

I\'d like to know if there is a way to uglify only one file in command line using r.js (RequireJS Optimizer) which is already installed in my computer. Like we can minify a css

3条回答
  •  野的像风
    2021-01-21 20:21

    I'll address how you can copy over a node package directly from one computer, because with this trick you'll have uglify, or clean-css or whatever package you want.

    The background is that a node package includes copies of all its dependencies underneath its own install directory - this makes it easy to grab an entire package by a simple cp -r or xcopy if you're on Windows (which I don't claim to support)

    Assuming one computer has an install of the clean-css package

    which cleancss

    should show a path such as /usr/local/share/npm/bin/cleancss, in which case you'll want to recursively copy /usr/local/share/npm/lib/node_modules/clean-css/ over to the other machine's corresponding node_modules folder (creating a symlink in /usr/local/share/npm/bin/ as well) to have access to that without the internet.

提交回复
热议问题