Socket
Socket
Sign inDemoInstall

grunt-min

Package Overview
Dependencies
97
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    grunt-min

minify javascript, css, image


Version published
Maintainers
1
Created

Readme

Source

grunt-min Build Status

使用示例

min任务可以压缩js脚本,css样式,html文档,json数据,jpg、png和gif图片

压缩
grunt.initConfig({
  min: {
    my_target: {
      files: {
        'dest/style.min.css': ['src/style.css'],
        'dest/script.min.js': ['src/input1.js', 'src/input2.js'],
	'dest/index.html': 'src/index.html',
	'dest/data.json': 'src/data.json',
	'dest/t.jpg': 'src/t.jpg'
      }
    }
  }
});
通过except参数可以保留变量名不被混淆
grunt.initConfig({
  uglify: {
    options: {
       except: ['$', 'Backbone']
    },
    my_target: {
      files: {
        'dest/output.min.js': ['src/input.js']
      }
    }
  }
});
grunt.initConfig({
  pkg: grunt.file.readJSON('package.json'),
  uglify: {
    options: {
      banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
        '<%= grunt.template.today("yyyy-mm-dd") %> */',
      
      footer: '/*end*/'
    },
    my_target: {
      options:{
        //不保留原有js中的注释
        copyright: false
      },
      files: {
        'dest/output.min.js': ['src/input.js']
      }
    }
  }
});
将整个文件夹中的脚本压缩
grunt.initConfig({
  min: {
    my_target: {
      files: [{
          expand: true,
          cwd: 'src/js',
          src: '**/*.js',
          dest: 'dest/js'
      }]
    }
  }
});

datauri任务可以将css文件进行DataURI编码

datauri
grunt.initConfig({
  datauri:{
    my_target: {
      'dest/datauri.css': 'src/style.css'
    }
  }
});

Release History

v0.1.0 2014-1-7


Task submitted by colorhook@gmail.com

Keywords

FAQs

Last updated on 07 Jan 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc