Compress js compress css

Compress js compress css

An easy-to-use module to compress your *.css , *.js and *.html files.

var gulp = require('gulp'),
options =
src: './src',
dest: './dist'
>;
require('gulp-compress')(gulp, options);

There are few tasks added in your gulp:

  • copy : Copy files which are match these glob to options.dest
  • compress-html :Compress *.html files which are under options.src then output to options.dest
  • compress-css :Compress *.css files which are under options.src then output to options.dest
  • compress-js :Compress *.js files which are under options.src then output to options.dest
  • compress :It’s run above tasks parallel.

All options and its default value are list on here. It’s really self-explanation.

var gulp = require('gulp'),
Compress = require('gulp-compress'),
cps = Compress(gulp);

Equal to require(‘gulp-uglify’) . See more info at gulp-uglify.

Equal to require(‘gulp-htmlmin’) . See more info at gulp-htmlmin.

Equal to require(‘gulp-minify-css’) . See more info at gulp-minify-css.

Copy files from globs to dest .

Compress js files from globs to dest .

Compress css files from globs to dest .

Compress html files from globs to dest .

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Beego Compress provides an automated system for compressing Css and JavaScript files

beego/compress

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Update html.go, thanks francoishill

Git stats

Files

Failed to load latest commit information.

README.md

Beego Compress provides an automated system for compressing JavaScript and Css files

It default use Google Closure Compiler for js, and Yui Compressor for css

After create a config file, you can simple use it in beego.

Move compiler.jar and yuicompressor.jar to your beego app path. Parallel with static path.

BTW: Of course you can integrated it with other framework or use it as a command line tool.

func SettingCompress() < // load json config file isProductMode := false setting, err := compress.LoadJsonConf("conf/compress.json", isProductMode, "http://127.0.0.1/") if err != nil < beego.Error(err) return > // after use this api, can run command from shell. setting.RunCommand() if isProductMode < // if in product mode, can use this api auto compress files setting.RunCompress(true, false, true) > // add func to FuncMap for template use beego.AddFuncMap("compress_js", setting.Js.CompressJs) beego.AddFuncMap("compress_css", setting.Css.CompressCss) >

Congratulations!! Let’s see html results.

Render result when isProductMode is false

link rel pl-s»>stylesheet» href pl-s»>http://127.0.0.1/static_source/css/bootstrap.css?ver=1382331000»/> link rel pl-s»>stylesheet» href pl-s»>http://127.0.0.1/static_source/css/bootstrap-theme.css?ver=1382322974»/> link rel pl-s»>stylesheet» href pl-s»>http://127.0.0.1/static_source/css/font-awesome.min.css?ver=1378615042»/> link rel pl-s»>stylesheet» href pl-s»>http://127.0.0.1/static_source/css/select2.css?ver=1382197742»/> script type pl-s»>text/javascript» src pl-s»>http://127.0.0.1/static_source/js/jquery.min.js?ver=1378644427«>script> script type pl-s»>text/javascript» src pl-s»>http://127.0.0.1/static_source/js/bootstrap.js?ver=1382328826«>script> script type pl-s»>text/javascript» src pl-s»>http://127.0.0.1/static_source/js/lib.min.js?ver=1382328441«>script> script type pl-s»>text/javascript» src pl-s»>http://127.0.0.1/static_source/js/jStorage.js?ver=1382271840«>script> script type pl-s»>text/javascript» src pl-s»>http://127.0.0.1/static_source/js/main.js?ver=1382195678«>script> script type pl-s»>text/javascript» src pl-s»>http://127.0.0.1/static_source/js/editor.js?ver=1382342779«>script>

Render result when isProductMode is true

link rel pl-s">stylesheet" href pl-s">http://127.0.0.1:8092/static/css/lib.min.css?ver=1382346563" /> script type pl-s">text/javascript" src pl-s">http://127.0.0.1:8092/static/js/lib.min.js?ver=1382346557">script> script type pl-s">text/javascript" src pl-s">http://127.0.0.1:8092/static/js/app.min.js?ver=1382346560">script>

note: All json key are not case sensitive

compress.json:

when use api setting.RunCommand()

$ go build app.go $ ./app compress compress command usage: js - compress all js files css - compress all css files all - compress all files $ ./app compress js -h Usage of compress command: js: -force=false: force compress file -skip=false: skip all cached file -v=false: verbose info $ ./app compress css -h Usage of compress command: css: -force=false: force compress file -skip=false: skip all cached file -v=false: verbose info 
use -force for re-create dist file but not skip cached. use -skip can skip all cached file and re-compress. 
  • TmpPath is default path of cached files.
  • Can modify JsFilters / CssFilters use your compress filter.
  • Can modify JsTagTemplate / CssTagTemplate with your tag.

All beego projects need your support.

Any suggestion are welcome, please add new issue let me known.

beego compress is licensed under the Apache Licence, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html).

About

Beego Compress provides an automated system for compressing Css and JavaScript files

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

🗜️ AstroJS compression utilities. Compress CSS, HTML, JavaScript and more!

License

astro-community/astro-compress

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

This Astro integration brings compression utilities to your Astro project.

Note

astro-compress will not compress your requests, only your statically generated build and pre-rendered routes.

Note

Use astro-compress last in your integration list for the best optimizations.

There are two ways to add integrations to your project. Let’s try the most convenient option first!

Astro includes a CLI tool for adding first party integrations: astro add . This command will:

  1. (Optionally) Install all necessary dependencies and peer dependencies
  2. (Also optionally) Update your astro.config.* file to apply this integration

To install astro-compress , run the following from your project directory and follow the prompts:

npx astro add astro-compress
yarn astro add astro-compress
pnpx astro add astro-compress

Install dependencies manually

First, install the astro-compress integration like so:

npm install -D -E astro-compress 

Then, apply this integration to your astro.config.* file using the integrations property:

astro.config.ts

import compress from "astro-compress"; export default  integrations: [compress()] >;

The utility will now automatically compress all your CSS, HTML, SVG, JavaScript and image files in the dist folder.

The following image file types will be compressed via sharp:

SVG compression is supported via svgo.

You can override any of the default options from the configurations of:

astro.config.ts

import compress from "astro-compress"; export default  integrations: [ compress( css: false, html: false, img: false, js: false, svg: false, >), ], >;

If your path is different than dist be sure to update it accordingly:

astro.config.ts

import compress from "astro-compress"; export default  outDir: "./build", integrations: [ compress( path: "./build", >), ], >;

You can add multiple paths to compress by specifying an array as the path variable.

astro.config.ts

import compress from "astro-compress"; export default  integrations: [ compress( path: ["./build", "./dist"], >), ], >;

You can also provide a map of paths for different input output directories.

astro.config.ts

import compress from "astro-compress"; export default  integrations: [ compress( path: new Map([["./input", "./output"]]), >), ], >;

astro.config.ts

import compress from "astro-compress"; export default  integrations: [ compress( path: [ // Compress dist "./dist", // Compress dist one more time into a different directory new Map([["./dist", "./dist-compressed"]]), ], >), ], >;

You can provide a filter to exclude files in your build. A filter can be an array of regexes or a single match. You can use functions, as well to match on file names.

astro.config.ts

import compress from "astro-compress"; export default  integrations: [ compress( exclude: [ "my-awesome.png", (file: string) => file === "./dist/img/favicon/safari-pinned-tab.svg", ], >), ], >;

Set logger to 0 if you do not want to see debug messages. Default is 2 .

astro.config.ts

import compress from "astro-compress"; export default  integrations: [ compress( logger: 0, >), ], >;

See CHANGELOG.md for a history of changes to this integration.

About

🗜️ AstroJS compression utilities. Compress CSS, HTML, JavaScript and more!

Источник

Читайте также:  Все семейства шрифтов css
Оцените статью