Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,169 @@
# 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.
<a name="1.1.5"></a>
## [1.1.5](https://github.com/webpack/file-loader/compare/v1.1.4...v1.1.5) (2017-10-05)
### Bug Fixes
* **schema:** allow `name` to be a `{Function}` (`options.name`) ([#216](https://github.com/webpack/file-loader/issues/216)) ([fbfb160](https://github.com/webpack/file-loader/commit/fbfb160))
<a name="1.1.4"></a>
## [1.1.4](https://github.com/webpack/file-loader/compare/v1.1.3...v1.1.4) (2017-09-30)
### Bug Fixes
* **index:** revert to CJS exports ([#212](https://github.com/webpack/file-loader/issues/212)) ([f412b3e](https://github.com/webpack/file-loader/commit/f412b3e))
<a name="1.1.3"></a>
## [1.1.3](https://github.com/webpack/file-loader/compare/v1.1.2...v1.1.3) (2017-09-30)
<a name="1.1.2"></a>
## [1.1.2](https://github.com/webpack/file-loader/compare/v1.1.1...v1.1.2) (2017-09-30)
### Bug Fixes
* **cjs:** export `raw` value ([#183](https://github.com/webpack/file-loader/issues/183)) ([daeff0e](https://github.com/webpack/file-loader/commit/daeff0e))
<a name="1.1.1"></a>
## [1.1.1](https://github.com/webpack/file-loader/compare/v1.1.0...v1.1.1) (2017-09-30)
### Bug Fixes
* **schema:** allow `additionalProperties` ([#207](https://github.com/webpack/file-loader/issues/207)) ([cf7c85a](https://github.com/webpack/file-loader/commit/cf7c85a))
<a name="1.1.0"></a>
# [1.1.0](https://github.com/webpack/file-loader/compare/v1.0.0...v1.1.0) (2017-09-29)
### Features
* add `options` validation (`schema-utils`) ([#184](https://github.com/webpack/file-loader/issues/184)) ([696ca77](https://github.com/webpack/file-loader/commit/696ca77))
<a name="1.0.0"></a>
# [1.0.0](https://github.com/webpack/file-loader/compare/v1.0.0-rc.0...v1.0.0) (2017-07-26)
### Bug Fixes
* remove `=` from default export (`SyntaxError`) ([#178](https://github.com/webpack/file-loader/issues/178)) ([3fe2d12](https://github.com/webpack/file-loader/commit/3fe2d12))
### Code Refactoring
* Upgrade to defaults 1.3.0 ([#170](https://github.com/webpack-contrib/file-loader/pull/170)) ([632ed72](https://github.com/webpack/file-loader/commit/acd6c2f))
* Apply webpack-defaults ([#167](https://github.com/webpack/file-loader/issues/167)) ([632ed72](https://github.com/webpack/file-loader/commit/632ed72))
### BREAKING CHANGES
* Enforces Webpack standard NodeJS engines range.
at the time of merge `>= 4.3 < 5.0.0 || >= 5.10`.
<a name="1.0.0-rc.0"></a>
# [1.0.0-rc.0](https://github.com/webpack/file-loader/compare/v1.0.0-beta.1...v1.0.0-rc.0) (2017-07-26)
### Bug Fixes
* remove `=` from default export (`SyntaxError`) ([#178](https://github.com/webpack/file-loader/issues/178)) ([3fe2d12](https://github.com/webpack/file-loader/commit/3fe2d12))
<a name="1.0.0-beta.1"></a>
# [1.0.0-beta.1](https://github.com/webpack/file-loader/compare/v1.0.0-beta.0...v1.0.0-beta.1) (2017-06-09)
### Code Refactoring
* Upgrade to defaults 1.3.0 ([#170](https://github.com/webpack-contrib/file-loader/pull/170)) ([632ed72](https://github.com/webpack/file-loader/commit/acd6c2f))
<a name="1.0.0-beta.0"></a>
# [1.0.0-beta.0](https://github.com/webpack/file-loader/compare/v0.11.2...v1.0.0-beta.0) (2017-06-07)
### Code Refactoring
* Apply webpack-defaults ([#167](https://github.com/webpack/file-loader/issues/167)) ([632ed72](https://github.com/webpack/file-loader/commit/632ed72))
### BREAKING CHANGES
* Enforces Webpack standard NodeJS engines range.
at the time of merge `>= 4.3 < 5.0.0 || >= 5.10`.
<a name="0.11.2"></a>
## [0.11.2](https://github.com/webpack/file-loader/compare/v0.11.1...v0.11.2) (2017-06-05)
### Bug Fixes
* **index:** allow to override publicPath with an empty string ([#145](https://github.com/webpack/file-loader/issues/145)) ([26ab81a](https://github.com/webpack/file-loader/commit/26ab81a))
* init `publicPath` to undefined ([#159](https://github.com/webpack/file-loader/issues/159)) ([e4c0b2a](https://github.com/webpack/file-loader/commit/e4c0b2a))
<a name="0.11.1"></a>
## [0.11.1](https://github.com/webpack/file-loader/compare/v0.11.0...v0.11.1) (2017-04-01)
### Bug Fixes
* outputPath function overriden by useRelativePath ([#139](https://github.com/webpack/file-loader/issues/139)) ([80cdee2](https://github.com/webpack/file-loader/commit/80cdee2))
<a name="0.11.0"></a>
# [0.11.0](https://github.com/webpack/file-loader/compare/v0.10.1...v0.11.0) (2017-03-31)
### Features
* Emit files with relative urls ([#135](https://github.com/webpack/file-loader/issues/135)) ([dbcd6cc](https://github.com/webpack/file-loader/commit/dbcd6cc))
<a name="0.10.1"></a>
## [0.10.1](https://github.com/webpack/file-loader/compare/v0.10.0...v0.10.1) (2017-02-25)
### Bug Fixes
* **getOptions:** deprecation warn in loaderUtils ([#129](https://github.com/webpack/file-loader/issues/129)) ([a8358a0](https://github.com/webpack/file-loader/commit/a8358a0))
<a name="0.10.0"></a>
# [0.10.0](https://github.com/webpack/file-loader/compare/v0.9.0...v0.10.0) (2017-01-28)
### Features
* **resources:** specify custom public file name ([6833c70](https://github.com/webpack/file-loader/commit/6833c70))
# 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.

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.

View File

@@ -0,0 +1,307 @@
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![tests][tests]][tests-url]
[![coverage][cover]][cover-url]
[![chat][chat]][chat-url]
<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>
<h1>File Loader</h1>
<p>Instructs webpack to emit the required object as file and to return its public URL</p>
</div>
<h2 align="center">Install</h2>
```bash
npm install --save-dev file-loader
```
<h2 align="center"><a href="https://webpack.js.org/concepts/loaders">Usage</a></h2>
By default the filename of the resulting file is the MD5 hash of the file's contents with the original extension of the required resource.
```js
import img from './file.png'
```
**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {}
}
]
}
]
}
}
```
Emits `file.png` as file in the output directory and returns the public URL
```
"/public/path/0dcbbaa7013869e351f.png"
```
<h2 align="center">Options</h2>
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|**`name`**|`{String\|Function}`|`[hash].[ext]`|Configure a custom filename template for your file|
|**`context`**|`{String}`|`this.options.context`|Configure a custom file context, defaults to `webpack.config.js` [context](https://webpack.js.org/configuration/entry-context/#context)|
|**`publicPath`**|`{String\|Function}`|[`__webpack_public_path__ `](https://webpack.js.org/api/module-variables/#__webpack_public_path__-webpack-specific-)|Configure a custom `public` path for your files|
|**`outputPath`**|`{String\|Function}`|`'undefined'`|Configure a custom `output` path for your files|
|**`useRelativePath`**|`{Boolean}`|`false`|Should be `true` if you wish to generate a `context` relative URL for each file|
|**`emitFile`**|`{Boolean}`|`true`|By default a file is emitted, however this can be disabled if required (e.g. for server side packages)|
### `name`
You can configure a custom filename template for your file using the query parameter `name`. For instance, to copy a file from your `context` directory into the output directory retaining the full directory structure, you might use
#### `{String}`
**webpack.config.js**
```js
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]'
}
}
```
#### `{Function}`
**webpack.config.js**
```js
{
loader: 'file-loader',
options: {
name (file) {
if (env === 'development') {
return '[path][name].[ext]'
}
return '[hash].[ext]'
}
}
}
```
#### `placeholders`
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|**`[ext]`**|`{String}`|`file.extname`|The extension of the resource|
|**`[name]`**|`{String}`|`file.basename`|The basename of the resource|
|**`[path]`**|`{String}`|`file.dirname`|The path of the resource relative to the `context`|
|**`[hash]`**|`{String}`|`md5`|The hash of the content, hashes below for more info|
|**`[N]`**|`{Number}`|``|The `n-th` match obtained from matching the current file name against the query param `regExp`|
#### `hashes`
`[<hashType>:hash:<digestType>:<length>]` optionally you can configure
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|**`hashType`**|`{String}`|`md5`|`sha1`, `md5`, `sha256`, `sha512`|
|**`digestType`**|`{String}`|`base64`|`hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`|
|**`length`**|`{Number}`|`8`|The length in chars|
By default, the path and name you specify will output the file in that same directory and will also use that same URL path to access the file.
### `context`
**webpack.config.js**
```js
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
context: ''
}
}
```
You can specify custom `output` and `public` paths by using `outputPath`, `publicPath` and `useRelativePath`
### `publicPath`
**webpack.config.js**
```js
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
publicPath: 'assets/'
}
}
```
### `outputPath`
**webpack.config.js**
```js
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
outputPath: 'images/'
}
}
```
### `useRelativePath`
`useRelativePath` should be `true` if you wish to generate a relative URL to the for each file context.
```js
{
loader: 'file-loader',
options: {
useRelativePath: process.env.NODE_ENV === "production"
}
}
```
### `emitFile`
By default a file is emitted, however this can be disabled if required (e.g. for server side packages).
```js
import img from './file.png'
```
```js
{
loader: 'file-loader',
options: {
emitFile: false
}
}
```
> ⚠️ Returns the public URL but does **not** emit a file
```
`${publicPath}/0dcbbaa701328e351f.png`
```
<h2 align="center">Examples</h2>
```js
import png from 'image.png'
```
**webpack.config.js**
```js
{
loader: 'file-loader',
options: {
name: 'dirname/[hash].[ext]'
}
}
```
```
dirname/0dcbbaa701328ae351f.png
```
**webpack.config.js**
```js
{
loader: 'file-loader',
options: {
name: '[sha512:hash:base64:7].[ext]'
}
}
```
```
gdyb21L.png
```
```js
import png from 'path/to/file.png'
```
**webpack.config.js**
```js
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]?[hash]'
}
}
```
```
path/to/file.png?e43b20c069c4a01867c31e98cbce33c9
```
<h2 align="center">Maintainers</h2>
<table>
<tbody>
<tr>
<td align="center">
<a href="https://github.com/bebraw">
<img width="150" height="150" src="https://github.com/bebraw.png?v=3&s=150">
</br>
Juho Vepsäläinen
</a>
</td>
<td align="center">
<a href="https://github.com/d3viant0ne">
<img width="150" height="150" src="https://github.com/d3viant0ne.png?v=3&s=150">
</br>
Joshua Wiens
</a>
</td>
<td align="center">
<a href="https://github.com/michael-ciniawsky">
<img width="150" height="150" src="https://github.com/michael-ciniawsky.png?v=3&s=150">
</br>
Michael Ciniawsky
</a>
</td>
<td align="center">
<a href="https://github.com/evilebottnawi">
<img width="150" height="150" src="https://github.com/evilebottnawi.png?v=3&s=150">
</br>
Alexander Krasnoyarov
</a>
</td>
</tr>
<tbody>
</table>
[npm]: https://img.shields.io/npm/v/file-loader.svg
[npm-url]: https://npmjs.com/package/file-loader
[node]: https://img.shields.io/node/v/file-loader.svg
[node-url]: https://nodejs.org
[deps]: https://david-dm.org/webpack-contrib/file-loader.svg
[deps-url]: https://david-dm.org/webpack-contrib/file-loader
[tests]: http://img.shields.io/travis/webpack-contrib/file-loader.svg
[tests-url]: https://travis-ci.org/webpack-contrib/file-loader
[cover]: https://img.shields.io/codecov/c/github/webpack-contrib/file-loader.svg
[cover-url]: https://codecov.io/gh/webpack-contrib/file-loader
[chat]: https://badges.gitter.im/webpack/webpack.svg
[chat-url]: https://gitter.im/webpack/webpack

View File

@@ -0,0 +1,6 @@
'use strict';
var loader = require('./index');
module.exports = loader.default;
module.exports.raw = loader.raw;

View File

@@ -0,0 +1,88 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.raw = undefined;
exports.default = loader;
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _loaderUtils = require('loader-utils');
var _loaderUtils2 = _interopRequireDefault(_loaderUtils);
var _schemaUtils = require('schema-utils');
var _schemaUtils2 = _interopRequireDefault(_schemaUtils);
var _options = require('./options.json');
var _options2 = _interopRequireDefault(_options);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function loader(content) {
if (!this.emitFile) throw new Error('File Loader\n\nemitFile is required from module system');
var options = _loaderUtils2.default.getOptions(this) || {};
(0, _schemaUtils2.default)(_options2.default, options, 'File Loader');
var context = options.context || this.options.context;
var url = _loaderUtils2.default.interpolateName(this, options.name, {
context,
content,
regExp: options.regExp
});
var outputPath = '';
if (options.outputPath) {
// support functions as outputPath to generate them dynamically
outputPath = typeof options.outputPath === 'function' ? options.outputPath(url) : options.outputPath;
}
var filePath = this.resourcePath;
if (options.useRelativePath) {
var issuerContext = this._module && this._module.issuer && this._module.issuer.context || context;
var relativeUrl = issuerContext && _path2.default.relative(issuerContext, filePath).split(_path2.default.sep).join('/');
var relativePath = relativeUrl && `${_path2.default.dirname(relativeUrl)}/`;
// eslint-disable-next-line no-bitwise
if (~relativePath.indexOf('../')) {
outputPath = _path2.default.posix.join(outputPath, relativePath, url);
} else {
outputPath = relativePath + url;
}
url = relativePath + url;
} else if (options.outputPath) {
// support functions as outputPath to generate them dynamically
outputPath = typeof options.outputPath === 'function' ? options.outputPath(url) : options.outputPath + url;
url = outputPath;
} else {
outputPath = url;
}
var publicPath = `__webpack_public_path__ + ${JSON.stringify(url)}`;
if (options.publicPath !== undefined) {
// support functions as publicPath to generate them dynamically
publicPath = JSON.stringify(typeof options.publicPath === 'function' ? options.publicPath(url) : options.publicPath + url);
}
if (options.emitFile === undefined || options.emitFile) {
this.emitFile(outputPath, content);
}
// TODO revert to ES2015 Module export, when new CSS Pipeline is in place
return `module.exports = ${publicPath};`;
}
var raw = exports.raw = true;

View File

@@ -0,0 +1,19 @@
{
"type": "object",
"properties": {
"name": {},
"regExp": {},
"context": {
"type": "string"
},
"publicPath": {},
"outputPath": {},
"useRelativePath": {
"type": "boolean"
},
"emitFile": {
"type": "boolean"
}
},
"additionalProperties": true
}

View File

@@ -0,0 +1,107 @@
{
"_args": [
[
"file-loader@1.1.5",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "file-loader@1.1.5",
"_id": "file-loader@1.1.5",
"_inBundle": false,
"_integrity": "sha512-RzGHDatcVNpGISTvCpfUfOGpYuSR7HSsSg87ki+wF6rw1Hm0RALPTiAdsxAq1UwLf0RRhbe22/eHK6nhXspiOQ==",
"_location": "/react-scripts/file-loader",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "file-loader@1.1.5",
"name": "file-loader",
"escapedName": "file-loader",
"rawSpec": "1.1.5",
"saveSpec": null,
"fetchSpec": "1.1.5"
},
"_requiredBy": [
"/react-scripts"
],
"_resolved": "https://registry.npmjs.org/file-loader/-/file-loader-1.1.5.tgz",
"_spec": "1.1.5",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"author": {
"name": "Tobias Koppers @sokra"
},
"bugs": {
"url": "https://github.com/webpack/file-loader/issues"
},
"dependencies": {
"loader-utils": "^1.0.2",
"schema-utils": "^0.3.0"
},
"description": "file loader module for webpack",
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-jest": "^20.0.3",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.5.1",
"cross-env": "^5.0.0",
"del-cli": "^1.0.0",
"eslint": "^3.19.0",
"eslint-config-webpack": "^1.2.3",
"eslint-plugin-import": "^2.3.0",
"jest": "^20.0.4",
"lint-staged": "^3.6.0",
"nsp": "^2.6.3",
"pre-commit": "^1.2.2",
"standard-version": "^4.0.0",
"webpack": "^3.6.0",
"webpack-defaults": "^1.6.0"
},
"directories": {
"test": "test"
},
"engines": {
"node": ">= 4.3 < 5.0.0 || >= 5.10"
},
"files": [
"dist"
],
"homepage": "https://github.com/webpack/file-loader",
"license": "MIT",
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
]
},
"main": "dist/cjs.js",
"name": "file-loader",
"peerDependencies": {
"webpack": "^2.0.0 || ^3.0.0"
},
"pre-commit": "lint-staged",
"repository": {
"type": "git",
"url": "git+https://github.com/webpack/file-loader.git"
},
"scripts": {
"appveyor:test": "npm run test",
"build": "cross-env NODE_ENV=production babel src -d dist --ignore 'src/**/*.test.js' --copy-files",
"clean": "del-cli dist",
"lint": "eslint --cache src test",
"lint-staged": "lint-staged",
"prebuild": "npm run clean",
"prepublish": "npm run build",
"release": "standard-version",
"security": "nsp check",
"start": "npm run build -- -w",
"test": "jest",
"test:coverage": "jest --collectCoverageFrom='src/**/*.js' --coverage",
"test:watch": "jest --watch",
"travis:coverage": "npm run test:coverage -- --runInBand",
"travis:lint": "npm run lint && npm run security",
"travis:test": "npm run test -- --runInBand",
"webpack-defaults": "webpack-defaults"
},
"version": "1.1.5"
}