use base64
encode file in js
and css
(includes sass
/less
etc.)
the plugin will unlink file in production
(parcel env).
if you use Parcel 1.x, you should install
parcel-plugin-url-loader@1.3.1
.
npm i parcel-transformer-url-loader -D
yarn add parcel-transformer-url-loader --dev
you must define glob in .parcelrc
to match files for the transformer of parcel-transformer-url-loader
.
for example:
// .parcelrc
{
"extends": "@parcel/config-default",
"transformers": {
"*.{png,jpg,jpeg}": ["parcel-transformer-url-loader"]
}
}
✨✨✨ If you have used url-loader
in webpack
, you'll feel familiar with it.
{
"parcel-transformer-url-loader": {
"limit": 10240
}
}
you can define "parcel-transformer-url-loader" in you package.json
.
for example:
{
"name": "your project",
"scripts": {},
"parcel-transformer-url-loader": {
"limit": 8888
}
}