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

@hdsydsvenskan/asset-versions

Package Overview
Dependencies
Maintainers
11
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hdsydsvenskan/asset-versions

CLI and helper methods for our asset versions

  • 4.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
408
increased by37.84%
Maintainers
11
Weekly downloads
 
Created
Source

Asset Versions

CLI and helper methods for asset versioning. Includes support for Webpack chunking.

Installation

npm install --save-dev @hdsydsvenskan/asset-versions

Release new version

Follow Semantic Versioning and use np and a version like patch | minor | major | prepatch | preminor | premajor | prerelease | 1.2.3

np patch

Example

See a full example, including Webpack support, in example/ folder and/or run the start npm script (run yarn start / npm start).

Usage

Generate asset version through CLI

  1. Add an assets.json
  2. Run asset-versions
  3. Get an assets-versioned.json file

Programmaticly access versioned paths

const AssetVersions = require('@hdsydsvenskan/asset-versions');

const assets = new AssetVersions({
  assetDefinitions: __dirname + '/assets.json'
});

// Returns something like 'assets/rev/main-e508b3af03.css'
assets.getAssetPath('assets/main.css');

Or, in case of code splitted javascript (likely through the use of Webpack):

// Returns something like ['assets/rev/main-e508b3af03.js', 'assets/rev/vendor-abc123.js']
assets.getAssetPathWithDependencies('assets/main.js');

Configure asset versions

Create a assets.json file:

{
  "sourceDir": "assets",
  "targetDir": "assets/rev/",
  "files": [
    "main.css",
    "main-dev.css",
    "main.js"
  ]
}

Configuration options

  • versions file name – both the cli (through the --output/ -o flag) and the module (through the versionsFileName option) can be tweaked to use another versions file than the default asset-versions.json

Extras

  • AssetVersions.baseAppPlugin – for use with @hdsydsvenskan/base-web-app
  • AssetVersions.webpackManifestPluginGenerate – a generate method for use with webpack-manifest-plugin to generate manifest with dependencies

FAQs

Package last updated on 21 Jul 2020

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