Automatic minification with nodeJS and Gulp task runner

前端 未结 2 1938
我寻月下人不归
我寻月下人不归 2021-01-13 06:15

I need some advices to improve automatic minification with node and gulp.

The main objective is generate dynamically the minified files(for JS and LESS) in developme

2条回答
  •  野的像风
    2021-01-13 07:08

    What i normally is exactly what you would like to avoid.. :)

    During development i have some watchers who are linting js files, translating stylus to css and generating my static html partials from jade. Their final step is to use the wonderful gulp-inject plugin for putting a call to the unminified assets in my index file. All these files are put in the build folder.

    When I want to test my production environment I have a dist task who takes all the assets present in the build folder concatenates and minify them, apply a rev suffix to the name for cache busting and with gulp-inject i'll update the index.html file with the minified assets links.

    In the server I check the environment and instruct express (with the serve-static package) to serve the build or dist folders accordingly.

    While creating your Web site in Azure you can specify your process.env.NODE_ENV value so you should be good to go with no runtime modifications to your code.

提交回复
热议问题