@zerollup/plugin-assets

Rollup assets plugin

renamed to @zerollup/rollup-plugin-assets
Last updated a year ago by zerkalica .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @zerollup/plugin-assets 
SYNC missed versions from official npm registry.

Rollup assets plugin

The best assets (fonts and images) management for rollup. Automatically gather assets from all packages/libraries.

  1. Detect asset in import import faceAngel from './face-angel.png'
  2. Generate human-friendly unique asset path: config.assetsUrl + 'my-package/face-angel.png'
  3. Base url for all assets configurable in runtime, see zerollup/injector
  4. Copy resources to dist/i/<pkg.name>/* directory of package
  5. When building application - extracts assets from packages and copy them to dist/i/<pkg.names>/

Example zerollup demo site.

Library

my-unique-lib/src/index.ts

import faceAngel from './face-angel.png'

export {faceAngel}

Transpiled my-unique-lib/dist/index.js

import { config } from '@zerollup/injector';

var faceAngel = config.assetsUrl + "my-unique-lib/face_angel.png"

export { faceAngel };

ls my-unique-lib/dist/i:

my-unique-lib/
    face_angel.png

Application

my-unique-app/src/index.ts

import {faceAngel} from 'my-unique-lib'

console.log(faceAngel)

my-unique-app/dist/index.js

var myUniqueApp = (function () {
    'use strict';

    var baseUrl = {
        assets: '/'
    };

    var faceAngel = baseUrl.assets + "my-unique-lib/face_angel.png";

    console.log(faceAngel);

}());

ls my-unique-app/dist/i:

my-unique-lib/
    face_angel.png

Setup

Example rollup.config.js

const pkg = require('./package.json')

export default {
    plugins: [
        // ...
        assets({
            name: pkg.name,
            pkgRoot: process.cwd(),
            isLib: true
        })
    ]
}

For complex usage see zerollup preset-ts

For typescript

Install typescript asset module resolver fix:

cp -rf ./node_modules/@zerollup/base-url/@types/assets-fix ./node_modules/@types

Current Tags

  • 1.2.2                                ...           latest (a year ago)

22 Versions

  • 1.2.2 [deprecated]           ...           a year ago
  • 1.1.4 [deprecated]           ...           a year ago
  • 1.1.3 [deprecated]           ...           a year ago
  • 1.0.24 [deprecated]           ...           a year ago
  • 1.0.23 [deprecated]           ...           a year ago
  • 1.0.22 [deprecated]           ...           a year ago
  • 1.0.21 [deprecated]           ...           a year ago
  • 1.0.20 [deprecated]           ...           a year ago
  • 1.0.19 [deprecated]           ...           a year ago
  • 1.0.18 [deprecated]           ...           a year ago
  • 1.0.17 [deprecated]           ...           a year ago
  • 1.0.16 [deprecated]           ...           a year ago
  • 1.0.15 [deprecated]           ...           a year ago
  • 1.0.14 [deprecated]           ...           a year ago
  • 1.0.13 [deprecated]           ...           a year ago
  • 1.0.12 [deprecated]           ...           a year ago
  • 1.0.11 [deprecated]           ...           a year ago
  • 1.0.7 [deprecated]           ...           a year ago
  • 1.0.5 [deprecated]           ...           a year ago
  • 1.0.4 [deprecated]           ...           a year ago
  • 1.0.3 [deprecated]           ...           a year ago
  • 1.0.2 [deprecated]           ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 44
Dependencies (3)
Dev Dependencies (1)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |