├── .gitignore ├── .npmrc ├── .editorconfig ├── lib └── module.js ├── package.json ├── CHANGELOG.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | @daliborgogic:registry=https://npm.pkg.github.com/ 2 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /lib/module.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require('path') 2 | const BrotliPlugin = require('brotli-webpack-plugin') 3 | 4 | module.exports = function (moduleOptions) { 5 | this.extendBuild((config, { isDev }) => { 6 | if (isDev) return 7 | 8 | let options = this.options['nuxt-brotli'] || moduleOptions 9 | 10 | options.asset = options.asset || '[path].br[query]' 11 | options.test = options.test || /\.(js|css|html|svg)$/ 12 | options.threshold = options.threshold || 0 13 | options.minRatio = options.minRatio || 0.8 14 | 15 | config.plugins.push(new BrotliPlugin(options)) 16 | }) 17 | } 18 | 19 | module.exports.meta = require('./../package.json') 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nuxt-brotli", 3 | "version": "1.1.7", 4 | "description": "This Nuxt.js module compresses assets with Brotli compression algorithm using `iltorb]` library for serving it with `ngx_brotli`", 5 | "main": "lib/module.js", 6 | "directories": { 7 | "lib": "lib" 8 | }, 9 | "publishConfig": { 10 | "access": "public" 11 | }, 12 | "scripts": { 13 | "release": "standard-version && git push --follow-tags && npm publish" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/daliborgogic/nuxt-brotli.git" 18 | }, 19 | "keywords": [ 20 | "nuxt", 21 | "module", 22 | "brotli" 23 | ], 24 | "author": "Dalibor Gogic ", 25 | "license": "MIT", 26 | "bugs": { 27 | "url": "https://github.com/daliborgogic/nuxt-brotli/issues" 28 | }, 29 | "homepage": "https://github.com/daliborgogic/nuxt-brotli#readme", 30 | "dependencies": { 31 | "brotli-webpack-plugin": "^1.1.0" 32 | }, 33 | "devDependencies": { 34 | "standard-version": "^8.0.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ### [1.1.7](https://github.com/daliborgogic/nuxt-brotli/compare/v1.1.5...v1.1.7) (2020-06-03) 6 | 7 | ### [1.1.5](https://github.com/daliborgogic/nuxt-brotli/compare/v1.1.3...v1.1.5) (2020-06-03) 8 | 9 | ### [1.1.3](https://github.com/daliborgogic/nuxt-brotli/compare/v1.1.1...v1.1.3) (2020-06-03) 10 | 11 | 12 | ## [1.1.1](https://github.com/daliborgogic/nuxt-brotli/compare/v1.1.0...v1.1.1) (2018-10-23) 13 | 14 | 15 | ### Bug Fixes 16 | 17 | * change the development check ([421ad34](https://github.com/daliborgogic/nuxt-brotli/commit/421ad34)) 18 | * restore module configurations ([4f9106d](https://github.com/daliborgogic/nuxt-brotli/commit/4f9106d)) 19 | 20 | 21 | 22 | 23 | # [1.1.0](https://github.com/daliborgogic/nuxt-brotli/compare/v1.0.3...v1.1.0) (2018-10-20) 24 | 25 | 26 | ### Features 27 | 28 | * disable in development ([40cb8e7](https://github.com/daliborgogic/nuxt-brotli/commit/40cb8e7)) 29 | 30 | 31 | 32 | 33 | ## [1.0.3](https://github.com/daliborgogic/nuxt-brotli/compare/v1.0.2...v1.0.3) (2018-09-16) 34 | 35 | 36 | 37 | 38 | ## [1.0.2](https://github.com/daliborgogic/nuxt-brotli/compare/v1.0.1...v1.0.2) (2018-09-16) 39 | 40 | 41 | 42 | 43 | ## 1.0.1 (2018-09-16) 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nuxt-brotli 2 | 3 | > This [Nuxt.js](https://github.com/nuxt) module compresses assets with Brotli compression algorithm using [iltorb](https://github.com/MayhemYDG/iltorb) library for serving it with [ngx_brotli](https://github.com/google/ngx_brotli). 4 | 5 | ## Installation 6 | 7 | ```bash 8 | $ npm i nuxt-brotli 9 | ``` 10 | 11 | ## Usage 12 | 13 | Add ```nuxt-brotli``` to modules section of ```nuxt.config.js``` 14 | 15 | ```javascript 16 | { 17 | modules: ['nuxt-brotli'] 18 | } 19 | ``` 20 | 21 | Arguments: 22 | 23 | * `asset`: The target asset name. Defaults to `'[path].br[query]'`. 24 | * `[file]` is replaced with the original asset file name. 25 | * `[fileWithoutExt]` is replaced with the file name minus its extension, e.g. the `style` of `style.css`. 26 | * `[ext]` is replaced with the file name extension, e.g. the `css` of `style.css`. 27 | * `[path]` is replaced with the path of the original asset. 28 | * `[query]` is replaced with the query. 29 | * `test`: All assets matching this RegExp are processed. Defaults to ```/\.(js|css|html|svg)$/```. 30 | * `threshold`: Only assets bigger than this size (in bytes) are processed. Defaults to `0`. 31 | * `minRatio`: Only assets that compress better that this ratio are processed. Defaults to `0.8`. 32 | * `deleteOriginalAssets`: remove original files that were compressed with brotli. Default: false 33 | 34 | Optional arguments for Brotli (see [iltorb](https://github.com/MayhemYDG/iltorb#brotliencodeparams) doc for details): 35 | * `mode`: Default: 0, 36 | * `quality`: Default: 11, 37 | * `lgwin`: Default: 22, 38 | * `lgblock`: Default: 0, 39 | * `size_hint`: Default: 0, 40 | * `disable_literal_context_modeling`: Default: false 41 | 42 | # License 43 | 44 | [Nuxt.js](https://github.com/nuxt) 45 | 46 | [iltorb](https://github.com/MayhemYDG/iltorb) 47 | 48 | [brotli plugin for webpack](https://github.com/mynameiswhm/brotli-webpack-plugin) 49 | 50 | [MIT](https://opensource.org/licenses/MIT) 51 | --------------------------------------------------------------------------------