Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
babel-plugin-file-loader
Advanced tools
Readme
Works the same as Webpack's file-loader, but on server side. With 95% test coverage!
yarn add babel-plugin-file-loader
Or if you like npm:
npm install babel-plugin-file-loader --save
Then put following "file-loader" as plugin in .babelrc:
{
"plugins": ["file-loader"]
}
This is equivalent to following default configuration:
{
"plugins": [
[
"file-loader",
{
"name": "[hash].[ext]",
"extensions": ["png", "jpg", "jpeg", "gif", "svg"],
"publicPath": "/public",
"outputPath": "/public",
"context": "",
"limit": 0
}
]
]
}
More or less as follows:
import
and require
that reference files ending with one of "extensions"
$name
of resource by substituting placeholders in "name"
$ROOT/$outputPath/$name
where $ROOT
is .babelrc
location.import
and require
in code with "$publicPath/$name"
stringimport img from './file.png'
const img2 = require('./file.svg')
Puts 0dcbbaa7013869e351f.png
and 8d3fe267fe578005541.svg
in the /public
and replaces code with:
const img = "/public/0dcbbaa7013869e351f.png"
const img2 = "/public/8d3fe267fe578005541.svg"
For real-life example go to examples.
Tells where to put static files. By default it's "/public"
.
This path is relative to the root of project. Setting value null
prevents the plugin to copy the file.
Tells what prefix to output in the source. By default it's "/public"
as well but it can be even full url, like so: "http://cdn.example.com/foobar/"
In this case the resulting code is:
const img = "http://cdn.example.com/foobar/0dcbbaa7013869e351f.png"
The default is [hash].[ext]
where:
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, see below for more info |
The full format [hash]
is: [<hashType>:hash:<digestType>:<length>]
, where:
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} | 128 | The length in chars |
For example: [md5:hash:base58:8]
or [hash:base36]
.
List of extension file-loader should look for in imports. All other imports are ignored.
Path to directory relative to .babelrc
where application source resides. By default ""
, but can be e.g. "/src"
.
Value in byte to determine if the content is base64 inlined. In that case, the file is not copy to outputPath
. It replicates url-loader webpack loader behaviour.
Default is 0 which means nothing is inlined.
Yes, please!
MIT
FAQs
Like file-loader for webpack, but for Babel. Works with SSE apps.
The npm package babel-plugin-file-loader receives a total of 16,966 weekly downloads. As such, babel-plugin-file-loader popularity was classified as popular.
We found that babel-plugin-file-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.