├── .eslintignore ├── .gitattributes ├── test ├── fixtures │ └── a.js.gz └── loader.test.js ├── .prettierrc ├── codecov.yml ├── .github ├── CODEOWNERS ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE.md ├── .gitignore ├── CHANGELOG.md ├── .editorconfig ├── .eslintrc.js ├── index.js ├── commitlint.config.js ├── LICENSE ├── package.json ├── README.md └── .circleci └── config.yml /.eslintignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /dist -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | yarn.lock -diff 2 | * text=auto 3 | bin/* eol=lf 4 | package-lock.json -diff -------------------------------------------------------------------------------- /test/fixtures/a.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webpack-contrib/gzip-loader/HEAD/test/fixtures/a.js.gz -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "es5", 4 | "arrowParens": "always" 5 | } 6 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | branch: master 3 | coverage: 4 | precision: 2 5 | round: down 6 | range: 70...100 7 | status: 8 | project: 'no' 9 | patch: 'yes' 10 | comment: 'off' 11 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # These are the default owners for everything in 2 | # webpack-contrib 3 | @webpack-contrib/org-maintainers 4 | 5 | # Add repository specific users / groups 6 | # below here for libs that are not maintained by the org. 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | logs 2 | *.log 3 | npm-debug.log* 4 | yarn-debug.log* 5 | .eslintcache 6 | /coverage 7 | /dist 8 | /local 9 | /reports 10 | /node_modules 11 | .DS_Store 12 | Thumbs.db 13 | .idea 14 | .vscode 15 | *.sublime-project 16 | *.sublime-workspace -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 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 | 0.0.1 / 2017-05-05 6 | ================== 7 | 8 | * Initial release 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | insert_final_newline = false 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | plugins: ['prettier'], 4 | extends: ['@webpack-contrib/eslint-config-webpack'], 5 | rules: { 6 | 'prettier/prettier': [ 7 | 'error', 8 | { singleQuote: true, trailingComma: 'es5', arrowParens: 'always' }, 9 | ], 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const { gunzip } = require('zlib'); 2 | 3 | module.exports = function loader(buf) { 4 | const callback = this.async(); 5 | this.cacheable(true); 6 | gunzip(buf, (err, unzipped) => { 7 | if (err) { 8 | callback(err); 9 | } else { 10 | callback(err, unzipped); 11 | } 12 | }); 13 | }; 14 | 15 | module.exports.raw = true; 16 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | const Configuration = { 3 | extends: ['@commitlint/config-angular'], 4 | 5 | rules: { 6 | 'body-leading-blank': [1, 'always'], 7 | 'footer-leading-blank': [1, 'always'], 8 | 'header-max-length': [2, 'always', 72], 9 | 'scope-case': [2, 'always', 'lower-case'], 10 | 'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']], 11 | 'subject-empty': [2, 'never'], 12 | 'subject-full-stop': [2, 'never', '.'], 13 | 'type-case': [2, 'always', 'lower-case'], 14 | 'type-empty': [2, 'never'], 15 | 'type-enum': [2, 'always', [ 16 | 'build', 17 | 'chore', 18 | 'ci', 19 | 'docs', 20 | 'feat', 21 | 'fix', 22 | 'perf', 23 | 'refactor', 24 | 'revert', 25 | 'style', 26 | 'test', 27 | ] 28 | ], 29 | }, 30 | }; 31 | 32 | module.exports = Configuration; 33 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 10 | 11 | This PR contains a: 12 | 13 | - [ ] **bugfix** 14 | - [ ] new **feature** 15 | - [ ] **code refactor** 16 | - [ ] **test update** 17 | - [ ] **typo fix** 18 | - [ ] **metadata update** 19 | 20 | ### Motivation / Use-Case 21 | 22 | 27 | 28 | ### Breaking Changes 29 | 30 | 34 | 35 | ### Additional Info 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | 'Software'), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /test/loader.test.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const MemoryFS = require('memory-fs'); 3 | const webpack = require('webpack'); 4 | 5 | const fs = new MemoryFS(); 6 | const loaderPath = path.join(__dirname, '../'); 7 | const fixturesPath = path.join(__dirname, 'fixtures'); 8 | const outputPath = path.join(__dirname, 'output'); 9 | 10 | const baseConfig = { 11 | module: { 12 | rules: [ 13 | { 14 | test: /\.gz$/, 15 | enforce: 'pre', 16 | use: loaderPath, 17 | }, 18 | ], 19 | }, 20 | }; 21 | 22 | test('loads gzipped file', () => 23 | new Promise((resolve) => { 24 | const filename = 'a.js'; 25 | const filepath = path.join(outputPath, filename); 26 | const compiler = webpack( 27 | Object.assign({}, baseConfig, { 28 | entry: path.join(fixturesPath, `${filename}.gz`), 29 | output: { path: outputPath, filename }, 30 | }) 31 | ); 32 | 33 | compiler.outputFileSystem = fs; 34 | compiler.run(() => { 35 | const content = fs.readFileSync(filepath, 'utf8'); 36 | expect(content).toMatch('const a = 1'); 37 | resolve(); 38 | }); 39 | })); 40 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 11 | 12 | * Operating System: 13 | * Node Version: 14 | * NPM Version: 15 | * webpack Version: 16 | * webpack-serve Version: 17 | 18 | 19 | 20 | This issue is for a: 21 | 22 | - [ ] **bug** 23 | - [ ] **feature** request 24 | - [ ] **modification** request 25 | 26 | ### Code 27 | 28 | ##### CLI Command 29 | 30 | ```bash 31 | # paste the CLI command you're using. if this isn't applicable, it's safe to remove. 32 | $ {the command} 33 | ``` 34 | 35 | ##### webpack.config.js 36 | 37 | ```js 38 | // If your bitchin' code blocks are over 20 lines, please paste a link to a gist 39 | // (https://gist.github.com). 40 | ``` 41 | 42 | ```js 43 | // additional code, HEY YO remove this block if you don't need it 44 | ``` 45 | 46 | ### Expected Behavior 47 | 48 | 49 | 50 | ### Actual Behavior 51 | 52 | 53 | 54 | ### How Do We Reproduce? 55 | 56 | 62 | 63 | ### New Feature Use Case 64 | 65 | 66 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gzip-loader", 3 | "version": "0.0.1", 4 | "description": "gzip loader module for webpack", 5 | "license": "MIT", 6 | "repository": "webpack-contrib/gzip-loader", 7 | "author": "John-David Dalton ", 8 | "homepage": "https://github.com/webpack-contrib/gzip-loader", 9 | "bugs": "https://github.com/webpack-contrib/gzip-loader/issues", 10 | "main": "index.js", 11 | "engines": { 12 | "node": ">= 6.9.0" 13 | }, 14 | "scripts": { 15 | "commitlint": "commitlint", 16 | "commitmsg": "commitlint -e $GIT_PARAMS", 17 | "lint": "eslint --cache src test", 18 | "ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}", 19 | "lint-staged": "lint-staged", 20 | "release": "standard-version", 21 | "release:ci": "conventional-github-releaser -p angular", 22 | "release:validate": "commitlint --from=$(git describe --tags --abbrev=0) --to=$(git rev-parse HEAD)", 23 | "security": "nsp check", 24 | "test": "jest --env=node", 25 | "test:watch": "jest --watch", 26 | "test:coverage": "jest --collectCoverageFrom='src/**/*.js' --coverage", 27 | "ci:lint": "npm run lint && npm run security", 28 | "ci:test": "npm run test -- --runInBand", 29 | "ci:coverage": "npm run test:coverage -- --runInBand", 30 | "defaults": "webpack-defaults" 31 | }, 32 | "files": [ 33 | "index.js" 34 | ], 35 | "peerDependencies": { 36 | "webpack": "^4.3.0" 37 | }, 38 | "dependencies": { 39 | "loader-utils": "^1.1.0", 40 | "schema-utils": "^0.4.5" 41 | }, 42 | "devDependencies": { 43 | "@commitlint/cli": "^6.1.3", 44 | "@commitlint/config-angular": "^6.1.3", 45 | "@webpack-contrib/eslint-config-webpack": "^2.0.2", 46 | "babel-cli": "^6.24.1", 47 | "babel-jest": "^19.0.0", 48 | "babel-plugin-transform-object-rest-spread": "^6.23.0", 49 | "babel-polyfill": "^6.23.0", 50 | "babel-preset-env": "^1.3.3", 51 | "conventional-github-releaser": "^2.0.2", 52 | "cross-env": "^4.0.0", 53 | "del": "^3.0.0", 54 | "del-cli": "^0.2.1", 55 | "eslint": "^3.19.0", 56 | "eslint-config-webpack": "^1.2.1", 57 | "eslint-plugin-import": "^2.2.0", 58 | "eslint-plugin-prettier": "^2.6.0", 59 | "husky": "^0.14.3", 60 | "jest": "^19.0.2", 61 | "lint-staged": "^3.4.0", 62 | "memory-fs": "^0.4.1", 63 | "nodemon": "^1.11.0", 64 | "nsp": "^2.6.3", 65 | "pre-commit": "^1.2.2", 66 | "prettier": "^1.11.1", 67 | "standard-version": "^4.0.0", 68 | "webpack": "^2.3.3", 69 | "webpack-defaults": "^2.1.1" 70 | }, 71 | "pre-commit": "lint-staged", 72 | "lint-staged": { 73 | "*.js": [ 74 | "eslint --fix", 75 | "git add" 76 | ] 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![npm][npm]][npm-url] 2 | [![deps][deps]][deps-url] 3 | [![test][test]][test-url] 4 | [![coverage][cover]][cover-url] 5 | [![chat][chat]][chat-url] 6 | 7 |
8 | 9 | 10 | 11 |

gzip-loader

12 |

gzip loader module for webpack

13 |
14 | 15 | Enables loading gzipped resources. 16 | 17 |

Install

18 | 19 | ```bash 20 | npm install --save-dev gzip-loader 21 | ``` 22 | 23 |

Usage

24 | 25 | **webpack.config.js** 26 | 27 | ```js 28 | module.exports = { 29 | module: { 30 | rules: [ 31 | { 32 | test: /\.gz$/, 33 | enforce: 'pre', 34 | use: 'gzip-loader' 35 | } 36 | ] 37 | } 38 | } 39 | ``` 40 | 41 | **bundle.js** 42 | 43 | ```js 44 | require("gzip-loader!./file.js.gz"); 45 | ``` 46 | 47 |

Maintainers

48 | 49 | 50 | 51 | 52 | 59 | 66 | 73 | 80 | 87 | 88 | 89 |
53 | 54 | 55 |
56 | John-David Dalton 57 |
58 |
60 | 61 | 62 |
63 | Juho Vepsäläinen 64 |
65 |
67 | 68 | 69 |
70 | Joshua Wiens 71 |
72 |
74 | 75 | 76 |
77 | Michael Ciniawsky 78 |
79 |
81 | 82 | 83 |
84 | Alexander Krasnoyarov 85 |
86 |
90 | 91 | [npm]: https://img.shields.io/npm/v/gzip-loader.svg 92 | [npm-url]: https://npmjs.com/package/gzip-loader 93 | 94 | [deps]: https://david-dm.org/webpack-contrib/gzip-loader.svg 95 | [deps-url]: https://david-dm.org/webpack-contrib/gzip-loader 96 | 97 | [chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg 98 | [chat-url]: https://gitter.im/webpack/webpack 99 | 100 | [test]: http://img.shields.io/travis/webpack-contrib/gzip-loader.svg 101 | [test-url]: https://travis-ci.org/webpack-contrib/gzip-loader 102 | 103 | [cover]: https://codecov.io/gh/webpack-contrib/gzip-loader/branch/master/graph/badge.svg 104 | [cover-url]: https://codecov.io/gh/webpack-contrib/gzip-loader 105 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | unit_tests: &unit_tests 2 | steps: 3 | - checkout 4 | - setup_remote_docker 5 | - restore_cache: 6 | key: dependency-cache-{{ checksum "package-lock.json" }} 7 | - run: 8 | name: NPM Rebuild 9 | command: npm install 10 | - run: 11 | name: Run unit tests. 12 | command: npm run ci:test 13 | # canary_tests: &canary_tests 14 | # steps: 15 | # - checkout 16 | # - setup_remote_docker 17 | # - restore_cache: 18 | # key: dependency-cache-{{ checksum "package-lock.json" }} 19 | # - run: 20 | # name: NPM Rebuild 21 | # command: npm install 22 | # - run: 23 | # name: Install Webpack Canary 24 | # command: npm i --no-save webpack@next 25 | # - run: 26 | # name: Run unit tests. 27 | # command: npm run ci:test 28 | 29 | version: 2 30 | jobs: 31 | dependency_cache: 32 | docker: 33 | - image: webpackcontrib/circleci-node-base:latest 34 | steps: 35 | - checkout 36 | - setup_remote_docker 37 | - restore_cache: 38 | key: dependency-cache-{{ checksum "package-lock.json" }} 39 | - run: 40 | name: Install Dependencies 41 | command: npm install 42 | - save_cache: 43 | key: dependency-cache-{{ checksum "package-lock.json" }} 44 | paths: 45 | - ./node_modules 46 | 47 | node8-latest: 48 | docker: 49 | - image: webpackcontrib/circleci-node8:latest 50 | steps: 51 | - checkout 52 | - setup_remote_docker 53 | - restore_cache: 54 | key: dependency-cache-{{ checksum "package-lock.json" }} 55 | - run: 56 | name: NPM Rebuild 57 | command: npm install 58 | - run: 59 | name: Run unit tests. 60 | command: npm run ci:coverage 61 | - run: 62 | name: Submit coverage data to codecov. 63 | command: bash <(curl -s https://codecov.io/bash) 64 | when: on_success 65 | node6-latest: 66 | docker: 67 | - image: webpackcontrib/circleci-node6:latest 68 | <<: *unit_tests 69 | node9-latest: 70 | docker: 71 | - image: webpackcontrib/circleci-node9:latest 72 | <<: *unit_tests 73 | # node8-canary: 74 | # docker: 75 | # - image: webpackcontrib/circleci-node8:latest 76 | # <<: *canary_tests 77 | analysis: 78 | docker: 79 | - image: webpackcontrib/circleci-node-base:latest 80 | steps: 81 | - checkout 82 | - setup_remote_docker 83 | - restore_cache: 84 | key: dependency-cache-{{ checksum "package-lock.json" }} 85 | - run: 86 | name: NPM Rebuild 87 | command: npm install 88 | - run: 89 | name: Run linting. 90 | command: npm run lint 91 | - run: 92 | name: Run NSP Security Check. 93 | command: npm run security 94 | - run: 95 | name: Validate Commit Messages 96 | command: npm run ci:lint:commits 97 | publish: 98 | docker: 99 | - image: webpackcontrib/circleci-node-base:latest 100 | steps: 101 | - checkout 102 | - setup_remote_docker 103 | - restore_cache: 104 | key: dependency-cache-{{ checksum "package-lock.json" }} 105 | - run: 106 | name: NPM Rebuild 107 | command: npm install 108 | - run: 109 | name: Validate Commit Messages 110 | command: npm run release:validate 111 | - run: 112 | name: Publish to NPM 113 | command: printf "noop running conventional-github-releaser" 114 | 115 | version: 2.0 116 | workflows: 117 | version: 2 118 | validate-publish: 119 | jobs: 120 | - dependency_cache 121 | - node6-latest: 122 | requires: 123 | - dependency_cache 124 | filters: 125 | tags: 126 | only: /.*/ 127 | - analysis: 128 | requires: 129 | - dependency_cache 130 | filters: 131 | tags: 132 | only: /.*/ 133 | - node8-latest: 134 | requires: 135 | - analysis 136 | - node6-latest 137 | filters: 138 | tags: 139 | only: /.*/ 140 | - node9-latest: 141 | requires: 142 | - analysis 143 | - node6-latest 144 | filters: 145 | tags: 146 | only: /.*/ 147 | # - node8-canary: 148 | # requires: 149 | # - analysis 150 | # - node6-latest 151 | # filters: 152 | # tags: 153 | # only: /.*/ 154 | - publish: 155 | requires: 156 | - node8-latest 157 | - node9-latest 158 | filters: 159 | branches: 160 | only: 161 | - master 162 | --------------------------------------------------------------------------------