first commit

This commit is contained in:
DanielRamirezGe
2020-01-14 20:43:08 -06:00
parent 3557894f7f
commit 5eecfbf6cd
26326 changed files with 2434803 additions and 0 deletions
+178
View File
@@ -0,0 +1,178 @@
# Changelog
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.
## [2.3.0](https://github.com/webpack-contrib/url-loader/compare/v2.2.0...v2.3.0) (2019-11-21)
### Features
* new `esModules` option to output ES modules ([0ee2b99](https://github.com/webpack-contrib/url-loader/commit/0ee2b9964f37f4d7c5dd6ea09f8526525e0fab91))
### [2.2.0](https://github.com/webpack-contrib/url-loader/compare/v2.1.0...v2.2.0) (2019-10-04)
### Features
* limit allow using `Infinity` and `Number` ([#192](https://github.com/webpack-contrib/url-loader/issues/192)) ([2bffcfd](https://github.com/webpack-contrib/url-loader/commit/2bffcfd))
* pnp support ([#195](https://github.com/webpack-contrib/url-loader/issues/195)) ([196110e](https://github.com/webpack-contrib/url-loader/commit/196110e))
## [2.1.0](https://github.com/webpack-contrib/url-loader/compare/v2.0.1...v2.1.0) (2019-07-18)
### Features
* improved validation error messages ([#187](https://github.com/webpack-contrib/url-loader/issues/187)) ([f3d4dd2](https://github.com/webpack-contrib/url-loader/commit/f3d4dd2))
### [2.0.1](https://github.com/webpack-contrib/url-loader/compare/v2.0.0...v2.0.1) (2019-06-25)
### Bug Fixes
* allow using limit as string when you use loader with query string ([#185](https://github.com/webpack-contrib/url-loader/issues/185)) ([4842f93](https://github.com/webpack-contrib/url-loader/commit/4842f93))
## [2.0.0](https://github.com/webpack-contrib/url-loader/compare/v1.1.2...v2.0.0) (2019-06-05)
### Bug Fixes
* rm unnecessary `bin` field ([#163](https://github.com/webpack-contrib/url-loader/issues/163)) ([b603665](https://github.com/webpack-contrib/url-loader/commit/b603665))
* `limit` should always be a number and 0 value handles as number ([#180](https://github.com/webpack-contrib/url-loader/issues/180)) ([d82e453](https://github.com/webpack-contrib/url-loader/commit/d82e453))
* fallback loader will be used than limit is equal or greater ([#179](https://github.com/webpack-contrib/url-loader/issues/179)) ([3c24545](https://github.com/webpack-contrib/url-loader/commit/3c24545))
### Features
* limit option can be boolean ([#181](https://github.com/webpack-contrib/url-loader/issues/181)) ([60d2cb3](https://github.com/webpack-contrib/url-loader/commit/60d2cb3))
### BREAKING CHANGES
* minimum required nodejs version is `8.9.0`
* `limit` should always be a number and 0 value handles as number
* fallback loader will be used than limit is equal or greater (before only when greater)
<a name="1.1.2"></a>
## [1.1.2](https://github.com/webpack-contrib/url-loader/compare/v1.1.0...v1.1.2) (2018-10-10)
### Bug Fixes
* fallback options behaviour ([#145](https://github.com/webpack-contrib/url-loader/issues/145)) ([03e631f](https://github.com/webpack-contrib/url-loader/commit/03e631f))
* **package:** add support for `webpack =< v3.0.0` (`peerDependencies`) ([#150](https://github.com/webpack-contrib/url-loader/issues/150)) ([a6860fc](https://github.com/webpack-contrib/url-loader/commit/a6860fc))
* **package:** relax `node` version range (`engines`) ([#155](https://github.com/webpack-contrib/url-loader/issues/155)) ([d37b108](https://github.com/webpack-contrib/url-loader/commit/d37b108))
* **utils/normalizeFallback:** correctly pass all `options` to the default fallback (`file-loader`) ([#139](https://github.com/webpack-contrib/url-loader/issues/139)) ([401be63](https://github.com/webpack-contrib/url-loader/commit/401be63))
<a name="1.1.1"></a>
## [1.1.1](https://github.com/webpack-contrib/url-loader/compare/v1.1.0...v1.1.1) (2018-08-17)
### Bug Fixes
* correctly pass all `options` to the fallback ([#143](https://github.com/webpack-contrib/url-loader/issues/143)) ([03e631f](https://github.com/webpack-contrib/url-loader/commit/03e631f))
<a name="1.1.0"></a>
# [1.1.0](https://github.com/webpack-contrib/url-loader/compare/v1.0.1...v1.1.0) (2018-08-13)
### Features
* support fallback loader in options.fallback ([#123](https://github.com/webpack-contrib/url-loader/issues/123)) ([017adc7](https://github.com/webpack-contrib/url-loader/commit/017adc7)), closes [#118](https://github.com/webpack-contrib/url-loader/issues/118)
<a name="1.0.1"></a>
## [1.0.1](https://github.com/webpack-contrib/url-loader/compare/v1.0.0...v1.0.1) (2018-03-03)
### Bug Fixes
* **index:** revert to CJS exports (`module.exports`) ([#116](https://github.com/webpack-contrib/url-loader/issues/116)) ([7b60cc2](https://github.com/webpack-contrib/url-loader/commit/7b60cc2))
<a name="1.0.0"></a>
# [1.0.0](https://github.com/webpack-contrib/url-loader/compare/v1.0.0-beta.0...v1.0.0) (2018-03-03)
### Bug Fixes
* **index:** use `Buffer.from` instead of deprecated `new Buffer` ([#113](https://github.com/webpack-contrib/url-loader/issues/113)) ([457618b](https://github.com/webpack-contrib/url-loader/commit/457618b))
<a name="1.0.0-beta.0"></a>
# [1.0.0-beta.0](https://github.com/webpack-contrib/url-loader/compare/v0.6.2...v1.0.0-beta.0) (2017-12-17)
### Code Refactoring
* apply `webpack-defaults` ([#102](https://github.com/webpack-contrib/url-loader/issues/102)) ([073b588](https://github.com/webpack-contrib/url-loader/commit/073b588))
### BREAKING CHANGES
* Sets `engines` to `"node": ">= 6.9.0 || >= 8.9.0"`
* Drops support for `webpack =< v2.0.0`
<a name="0.6.2"></a>
## [0.6.2](https://github.com/webpack-contrib/url-loader/compare/v0.6.1...v0.6.2) (2017-10-04)
### Bug Fixes
* allow use `limit` as string ([#96](https://github.com/webpack-contrib/url-loader/issues/96)) ([b31684d](https://github.com/webpack-contrib/url-loader/commit/b31684d))
<a name="0.6.1"></a>
## [0.6.1](https://github.com/webpack-contrib/url-loader/compare/v0.6.0...v0.6.1) (2017-10-04)
### Bug Fixes
* **schema:** allow `additionalProperties` ([#94](https://github.com/webpack-contrib/url-loader/issues/94)) ([2b01ea2](https://github.com/webpack-contrib/url-loader/commit/2b01ea2))
<a name="0.6.0"></a>
# [0.6.0](https://github.com/webpack-contrib/url-loader/compare/v0.5.9...v0.6.0) (2017-10-03)
### Features
* **index:** add options validation (`schema-utils`) ([#78](https://github.com/webpack-contrib/url-loader/issues/78)) ([ced5990](https://github.com/webpack-contrib/url-loader/commit/ced5990))
* add `fallback` option ([#88](https://github.com/webpack-contrib/url-loader/issues/88)) ([636ebed](https://github.com/webpack-contrib/url-loader/commit/636ebed))
### Security
* Updates Mime pacakge due to Regex DOS security vulnerability ([#87](https://github.com/webpack-contrib/url-loader/issues/87)) ([d19ee2d](https://github.com/webpack-contrib/url-loader/commit/d19ee2d))
- Reference issue https://nodesecurity.io/advisories/535
<a name="0.5.9"></a>
## [0.5.9](https://github.com/webpack/url-loader/compare/v0.5.8...v0.5.9) (2017-06-12)
### Bug Fixes
* `String` not being `base64` encoded ([#67](https://github.com/webpack/url-loader/issues/67)) ([e9496b9](https://github.com/webpack/url-loader/commit/e9496b9))
* don't default to `0` (`options.limit`) ([#74](https://github.com/webpack/url-loader/issues/74)) ([020c2a8](https://github.com/webpack/url-loader/commit/020c2a8))
# Change Log
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.
+20
View File
@@ -0,0 +1,20 @@
Copyright JS Foundation and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+234
View File
@@ -0,0 +1,234 @@
<div align="center">
<a href="https://github.com/webpack/webpack">
<img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
</a>
</div>
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![tests][tests]][tests-url]
[![chat][chat]][chat-url]
[![size][size]][size-url]
# url-loader
A loader for webpack which transforms files into base64 URIs.
## Getting Started
To begin, you'll need to install `url-loader`:
```console
$ npm install url-loader --save-dev
```
`url-loader` works like
[`file-loader`](https://github.com/webpack-contrib/file-loader), but can return
a DataURL if the file is smaller than a byte limit.
**index.js**
```js
import img from './image.png';
```
**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
},
},
],
},
],
},
};
```
And run `webpack` via your preferred method.
## Options
### `fallback`
Type: `String`
Default: `'file-loader'`
Specifies an alternative loader to use when a target file's size exceeds the
limit set in the `limit` option.
**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
fallback: require.resolve('responsive-loader'),
},
},
],
},
],
},
};
```
The fallback loader will receive the same configuration options as url-loader.
For example, to set the quality option of a responsive-loader above use:
**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
fallback: require.resolve('responsive-loader'),
quality: 85,
},
},
],
},
],
},
};
```
### `limit`
Type: `Number|Boolean|String`
Default: `undefined`
The limit can be specified via loader options and defaults to no limit.
#### `Number|String`
A `Number` or `String` specifying the maximum size of a file in bytes. If the file size is
**equal** or **greater** than the limit [`file-loader`](https://github.com/webpack-contrib/file-loader)
will be used (by default) and all query parameters are passed to it.
Using an alternative to `file-loader` is enabled via the `fallback` option.
**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
},
},
],
},
],
},
};
```
#### `Boolean`
Enable or disable transform files into base64.
**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: false,
},
},
],
},
],
},
};
```
### `mimetype`
Type: `String`
Default: `(file extension)`
Sets the MIME type for the file to be transformed. If unspecified the file
extensions will be used to lookup the MIME type.
**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
mimetype: 'image/png',
},
},
],
},
],
},
};
```
## Contributing
Please take a moment to read our contributing guidelines if you haven't yet done so.
[CONTRIBUTING](./.github/CONTRIBUTING.md)
## License
[MIT](./LICENSE)
[npm]: https://img.shields.io/npm/v/url-loader.svg
[npm-url]: https://npmjs.com/package/url-loader
[node]: https://img.shields.io/node/v/url-loader.svg
[node-url]: https://nodejs.org
[deps]: https://david-dm.org/webpack-contrib/url-loader.svg
[deps-url]: https://david-dm.org/webpack-contrib/url-loader
[tests]: https://dev.azure.com/webpack-contrib/url-loader/_apis/build/status/webpack-contrib.url-loader?branchName=master
[tests-url]: https://dev.azure.com/webpack-contrib/url-loader/_build/latest?definitionId=2&branchName=master
[cover]: https://codecov.io/gh/webpack-contrib/url-loader/branch/master/graph/badge.svg
[cover-url]: https://codecov.io/gh/webpack-contrib/url-loader
[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg
[chat-url]: https://gitter.im/webpack/webpack
[size]: https://packagephobia.now.sh/badge?p=url-loader
[size-url]: https://packagephobia.now.sh/result?p=url-loader
+6
View File
@@ -0,0 +1,6 @@
"use strict";
const loader = require('./index');
module.exports = loader.default;
module.exports.raw = loader.raw;
+81
View File
@@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = loader;
exports.raw = void 0;
var _loaderUtils = require("loader-utils");
var _schemaUtils = _interopRequireDefault(require("schema-utils"));
var _mime = _interopRequireDefault(require("mime"));
var _normalizeFallback = _interopRequireDefault(require("./utils/normalizeFallback"));
var _options = _interopRequireDefault(require("./options.json"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint-disable
global-require,
no-param-reassign,
prefer-destructuring,
import/no-dynamic-require,
*/
function shouldTransform(limit, size) {
if (typeof limit === 'boolean') {
return limit;
}
if (typeof limit === 'string') {
return size <= parseInt(limit, 10);
}
if (typeof limit === 'number') {
return size <= limit;
}
return true;
}
function loader(src) {
// Loader Options
const options = (0, _loaderUtils.getOptions)(this) || {};
(0, _schemaUtils.default)(_options.default, options, {
name: 'URL Loader',
baseDataPath: 'options'
}); // No limit or within the specified limit
if (shouldTransform(options.limit, src.length)) {
const file = this.resourcePath; // Get MIME type
const mimetype = options.mimetype || _mime.default.getType(file);
if (typeof src === 'string') {
src = Buffer.from(src);
}
return `${options.esModules ? 'export default' : 'module.exports ='} ${JSON.stringify(`data:${mimetype || ''};base64,${src.toString('base64')}`)}`;
} // Normalize the fallback.
const {
loader: fallbackLoader,
options: fallbackOptions
} = (0, _normalizeFallback.default)(options.fallback, options); // Require the fallback.
const fallback = require(fallbackLoader); // Call the fallback, passing a copy of the loader context. The copy has the query replaced. This way, the fallback
// loader receives the query which was intended for it instead of the query which was intended for url-loader.
const fallbackLoaderContext = Object.assign({}, this, {
query: fallbackOptions
});
return fallback.call(fallbackLoaderContext, src);
} // Loader Mode
const raw = true;
exports.raw = raw;
+46
View File
@@ -0,0 +1,46 @@
{
"type": "object",
"properties": {
"limit": {
"description": "Enables/Disables transformation target file into base64 URIs (https://github.com/webpack-contrib/url-loader#limit).",
"type": ["boolean", "number", "string"]
},
"mimetype": {
"description": "The MIME type for the file to be transformed (https://github.com/webpack-contrib/url-loader#mimetype).",
"type": "string"
},
"fallback": {
"description": "An alternative loader to use when a target file's size exceeds the limit set in the limit option (https://github.com/webpack-contrib/url-loader#fallback).",
"anyOf": [
{
"type": "string"
},
{
"additionalProperties": false,
"properties": {
"loader": {
"description": "Fallback loader name.",
"type": "string"
},
"options": {
"description": "Fallback loader options.",
"anyOf": [
{
"type": "object"
},
{
"type": "string"
}
]
}
},
"type": "object"
}
]
},
"esModules": {
"type": "boolean"
}
},
"additionalProperties": true
}
+39
View File
@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = normalizeFallback;
var _loaderUtils = _interopRequireDefault(require("loader-utils"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function normalizeFallback(fallback, originalOptions) {
let loader = 'file-loader';
let options = {};
if (typeof fallback === 'string') {
loader = fallback;
const index = fallback.indexOf('?');
if (index >= 0) {
loader = fallback.substr(0, index);
options = _loaderUtils.default.parseQuery(fallback.substr(index));
}
}
if (fallback !== null && typeof fallback === 'object') {
({
loader,
options
} = fallback);
}
options = Object.assign({}, originalOptions, options);
delete options.fallback;
return {
loader,
options
};
}
+112
View File
@@ -0,0 +1,112 @@
{
"_from": "url-loader@^2.2.0",
"_id": "url-loader@2.3.0",
"_inBundle": false,
"_integrity": "sha512-goSdg8VY+7nPZKUEChZSEtW5gjbS66USIGCeSJ1OVOJ7Yfuh/36YxCwMi5HVEJh6mqUYOoy3NJ0vlOMrWsSHog==",
"_location": "/url-loader",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "url-loader@^2.2.0",
"name": "url-loader",
"escapedName": "url-loader",
"rawSpec": "^2.2.0",
"saveSpec": null,
"fetchSpec": "^2.2.0"
},
"_requiredBy": [
"/@vue/cli-service"
],
"_resolved": "https://registry.npmjs.org/url-loader/-/url-loader-2.3.0.tgz",
"_shasum": "e0e2ef658f003efb8ca41b0f3ffbf76bab88658b",
"_spec": "url-loader@^2.2.0",
"_where": "/home/george/citwa/red_de_investigacion_front/first/node_modules/@vue/cli-service",
"author": {
"name": "Tobias Koppers @sokra"
},
"bugs": {
"url": "https://github.com/webpack-contrib/url-loader/issues"
},
"bundleDependencies": false,
"dependencies": {
"loader-utils": "^1.2.3",
"mime": "^2.4.4",
"schema-utils": "^2.5.0"
},
"deprecated": false,
"description": "A loader for webpack which transforms files into base64 URIs",
"devDependencies": {
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/preset-env": "^7.7.1",
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"@webpack-contrib/defaults": "^5.0.2",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^24.9.0",
"commitlint-azure-pipelines-cli": "^1.0.2",
"cross-env": "^6.0.3",
"del": "^5.1.0",
"del-cli": "^3.0.0",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-import": "^2.18.2",
"file-loader": "^4.2.0",
"husky": "^3.1.0",
"jest": "^24.9.0",
"jest-junit": "^9.0.0",
"lint-staged": "^9.4.3",
"memory-fs": "^0.5.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.1",
"standard-version": "^7.0.1",
"webpack": "^4.41.2"
},
"engines": {
"node": ">= 8.9.0"
},
"files": [
"dist"
],
"homepage": "https://github.com/webpack-contrib/url-loader",
"keywords": [
"webpack"
],
"license": "MIT",
"main": "dist/cjs.js",
"name": "url-loader",
"peerDependencies": {
"webpack": "^4.0.0",
"file-loader": "*"
},
"peerDependenciesMeta": {
"file-loader": {
"optional": true
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/webpack-contrib/url-loader.git"
},
"scripts": {
"build": "cross-env NODE_ENV=production babel src -d dist --ignore \"src/**/*.test.js\" --copy-files",
"clean": "del-cli dist",
"commitlint": "commitlint --from=master",
"defaults": "webpack-defaults",
"lint": "npm-run-all -l -p \"lint:**\"",
"lint:js": "eslint --cache src test",
"lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css}\" --list-different",
"prebuild": "npm run clean",
"prepare": "npm run build",
"pretest": "npm run lint",
"release": "standard-version",
"security": "npm audit",
"start": "npm run build -- -w",
"test": "cross-env NODE_ENV=test npm run test:coverage",
"test:coverage": "cross-env NODE_ENV=test jest --collectCoverageFrom=\"src/**/*.js\" --coverage",
"test:only": "cross-env NODE_ENV=test jest",
"test:watch": "cross-env NODE_ENV=test jest --watch"
},
"version": "2.3.0"
}