grunt-contrib-uglify

When I run Grunt, I receive the following message: Local npm module “grunt-contrib-copy” not found. Is it installed?

家住魔仙堡 提交于 2019-12-07 02:59:25
问题 I have been trying to install Grunt. When I run grunt I receive the following list of messages and warnings: Local Npm module "grunt-contrib-copy" not found. Is it installed? Local Npm module "grunt-contrib-uglify" not found. Is it installed? Local Npm module "grunt-contrib-jshint" not found. Is it installed? Local Npm module "grunt-contrib-less" not found. Is it installed? Local Npm module "grunt-contrib-clean" not found. Is it installed? Local Npm module "grunt-contrib-watch" not found. Is

How to use minified javascript?

江枫思渺然 提交于 2019-12-06 04:29:19
I have a grunt tasks to concat and minify all my javascript files into one single file and the javascript file is in dist folder. "dist/<%= pkg.name %>.min.js'" "Gruntfile.js" module.exports = function (grunt) { grunt.initConfig({ pkg: grunt.file.readJSON("package.json"), concat: { options: { separator: ';' }, dist: { src: ['src/main/resources/app/js/**/*.js', 'src/main/resources/app/config/*.js', 'src/main/resources/app/app/js'], dest: 'dist/<%= pkg.name %>.js' } }, uglify: { options: { banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n' }, dist: { files: { 'src/main

Grunt Uglify source map “unable to write”

﹥>﹥吖頭↗ 提交于 2019-12-05 13:34:40
I'm using Grunt to concat and minify files (with grunt-contrib-uglify and grunt-contrib-concat ) and I wanted to add a source map. The uglify docs say to just add an option for sourceMap set to a boolean of true. But when I add that to my tasks (I've tried a couple different ones) the process runs fine until it gets to the source map part, then I get: Writing true...ERROR Warning: Unable to write "true" file (Error code: undefined). Use --force to continue. The concatenation is done, the minification is done. But... no luck with the sourcemap. Sample from my Grunt file: uglify: { options: {

Disable minification in Grunt (Yeoman)

梦想的初衷 提交于 2019-12-05 10:36:38
I recently started using GruntJS through Yeoman and I like the idea of Javascript minification, but it presents difficulties during development. I tried to disable uglify,usemin, etc in different combinations in the Gruntfile but everything seems to be dependent on another thing and breaks the process. Is there a simple way to disable minification? I am using the latest versionof Grunt offered by Yeoman to date, I found that older solutions have a different Gruntfile setup than that usd with Yeoman. Here is my Gruntfile: // Reads HTML for usemin blocks to enable smart builds that automatically

When I run Grunt, I receive the following message: Local npm module “grunt-contrib-copy” not found. Is it installed?

依然范特西╮ 提交于 2019-12-05 07:55:30
I have been trying to install Grunt. When I run grunt I receive the following list of messages and warnings: Local Npm module "grunt-contrib-copy" not found. Is it installed? Local Npm module "grunt-contrib-uglify" not found. Is it installed? Local Npm module "grunt-contrib-jshint" not found. Is it installed? Local Npm module "grunt-contrib-less" not found. Is it installed? Local Npm module "grunt-contrib-clean" not found. Is it installed? Local Npm module "grunt-contrib-watch" not found. Is it installed? Local Npm module "grunt-contrib-concurrent" not found. Is it installed? Local Npm module

Combine and minify all bower libraries with gruntjs

痞子三分冷 提交于 2019-12-04 04:27:18
Is there a way to combine and minify all bower installed libraries into 1 file automatically? First I tried the most basic approach: combine all .js files from all subdirectories: uglify: { options: {compress: true}, my_target: { files: { 'vendor.js': ['bower_components/**/*.js'], } } } But this is obviously a bad approach. It also doesn't work because of too many errors. I manually deleted all the files and kept only 1 (main) file that each library has, and it worked. Is there a way to do this all automatically? Also, is it advisable to do it? (i.e. combine all vendor libraries into 1 file) I

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

心不动则不痛 提交于 2019-12-03 18:28:19
问题 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

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

断了今生、忘了曾经 提交于 2019-12-03 11:52:58
问题 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 ? 回答1: 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

How can I skip a grunt task if a directory is empty

ぐ巨炮叔叔 提交于 2019-12-03 07:03:49
I'm using grunt-contrib's concat and uglify modules to process some javascript. Currently if src/js/ is empty, they will still create an (empty) concat'd file, along with the minified version and a source map. I want to task to detect if the src/js/ folder is empty before proceeding, and if it is, then the task should skip (not fail). Any ideas how to do this? The solution may not be the prettiest, but could give you an idea. You'll need to run something like npm install --save-dev glob first. This is based on part of the Milkshake project you mentioned. grunt.registerTask('build_js', function

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

依然范特西╮ 提交于 2019-12-03 05:30:18
问题 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)