Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parcel-plugin-assets-list

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parcel-plugin-assets-list

Support assets list input file type

  • 1.3.0
  • npm
  • Socket score

Version published
Weekly downloads
13
Maintainers
1
Weekly downloads
 
Created
Source

Parcel Plugin for Assets Manifest

This plugin adds a new asset file type handler *.urls which reads a file of newline-separated file paths and adds them to the parcel outputs. Each file referenced in the list will be hashed by parcel and copied to the output folder (e.g. dist/)

To use this plugin, install it into your parcel project:

yarn add parcel-plugin-assets-list
# or
npm install parcel-plugin-assets-list

Then create an URLs file, for example a file assets.urls:

# HTML templates
templates/a.html
templates/b.html

# Stylesheets
scss/styles.scss

# Javascript
js/whatever.js

Server-side usage

To use the assets on the server side, pass the file directly to parcel build / watch, e.g.

parcel build assets.urls

Now you will get a file assets.json in the dist folder that you can load on the server-side to calculate asset URLs.

Client-side usage

To get asset URLs in client-side javascript, import the URLs as a JavaScript module, e.g.

import urls from './assets.urls'
const templateUrl = urls['templates/a.html']

Custom keys

By default the key in the generated mapping is the filename listed in the file. However, you can specify a specific key using a <key>: <path> format in the source file, e.g.

# assets.urls
templateUrl: templates/a.html

This makes importing the asset paths from JavaScript much more convenient:

# component.js
import { templateUrl } from 'assets.urls';

Asset Processing

Note that the target assets are compiled by Parcel, so .scss files will reference .css afterwards, .json files will end up references a .js file, and so on.

URL Prefix

If you pass --public-url that URL will be prefixed to the resolved asset URLs.

Example

The example folder has a sample project that shows how files are processed and what the output files look like.

FAQs

Package last updated on 19 May 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc