grunt-contrib-uglify

Change link or script filename in html after gruntjs minify/uglify

痴心易碎 提交于 2019-12-03 01:24:34
I am using standard minify/uglify for css/js files and combine multiple files to main.min.css or app.min.js... However my .html file needs to be modified to point to these new file names too in <link> or <script> Is there a way to automate this? Or how to modify .html files automatically to rename the file names in there using gruntjs ? You can do this with grunt-string-replace . Here's an example on how you could use it. In my index.html you find the following import tags: <!--start PROD imports <script src="assets/dist/traffic.min.js"></script> end PROD imports--> <!--start DEV imports-->

how to minify js files in order via grunt-contrib-uglify?

元气小坏坏 提交于 2019-12-02 18:47:56
I have a directory like below: /folder/b.js /folder/jQuery.js /folder/a.js /folder/sub/c.js I want to minify all these js files in one js file in order : jQuery.js -> a.js -> b.js -> c.js Q: 1.How can I do it via grunt-contrib-uglify?(In fact, there are lots of files, it is impractical to specify all source filepaths individually) 2.btw, How can I get unminified files when debug and get minified single file when release and no need to change script tag in html(and how to write the script tag)? Good questions! 1) Uglify will reorder the functions in the destination file so that function

How to grunt-uglify multiple script files while keeping folder structure

拟墨画扇 提交于 2019-11-29 21:50:08
I have not found a good way to grunt-uglify multiple script files spread over multiple folders while keeping the folder structure including the uglified files intact. The only reason I want to do this is to be able to increase the performance of the "legacy" part of the web page I'm working on. I have found a way around this which I don't want to do, since it will take to much time, and that is to do it like in this answer (they specify each src and dest pair seperately): how to config grunt.js to minify files separately An example of what I want to achieve: **src dir (no uglify applied):**

Grunt concat + uglify with sourcemaps

蓝咒 提交于 2019-11-28 17:14:06
I use concat to merge JS files into one file and uglify to minimize the JavaScript. How can I create a sourcemaps file that uses the source JS files? My current gruntfile: concat: { options: { // define a string to put between each file in the concatenated output separator: ';' }, dist: { // the files to concatenate src: ['<%= config.src %>/js/**/*.js'], // the location of the resulting JS file dest: '<%= config.dist %>/js/main.js' } }, uglify: { dist: { files: { '<%= config.dist %>/js/main.min.js': ['<%= concat.dist.dest %>'] } } }, Damon Friendship You need to enable source maps on both the

some es6 features are not understood by grunt uglify js?

被刻印的时光 ゝ 提交于 2019-11-28 11:58:18
I used grunt-uglify in my project and I'm working with es6. for some es6 features, such as fat arrow function, it's throwing an error. I think the uglify don't understant that syntax. so do i have a way to fix this issue. I mean can i use anything to make uglify understand all the es6 syntaxes? Officially there's no tool that minifies ES6 yet (Other tools like Google Closure compiler supports ES6 but it transpile it into "traditional js" and then it's minified). Although not all the es6 features are supported in UglifyJs, the Harmony branch of UglifyJS2 seems to support arrow functions and

Grunt concat + uglify with sourcemaps

你。 提交于 2019-11-27 10:30:10
问题 I use concat to merge JS files into one file and uglify to minimize the JavaScript. How can I create a sourcemaps file that uses the source JS files? My current gruntfile: concat: { options: { // define a string to put between each file in the concatenated output separator: ';' }, dist: { // the files to concatenate src: ['<%= config.src %>/js/**/*.js'], // the location of the resulting JS file dest: '<%= config.dist %>/js/main.js' } }, uglify: { dist: { files: { '<%= config.dist %>/js/main

some es6 features are not understood by grunt uglify js?

痞子三分冷 提交于 2019-11-27 06:38:38
问题 I used grunt-uglify in my project and I'm working with es6. for some es6 features, such as fat arrow function, it's throwing an error. I think the uglify don't understant that syntax. so do i have a way to fix this issue. I mean can i use anything to make uglify understand all the es6 syntaxes? 回答1: Officially there's no tool that minifies ES6 yet (Other tools like Google Closure compiler supports ES6 but it transpile it into "traditional js" and then it's minified). Although not all the es6