npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@eik/postcss-import-map

v2.0.4

Published

PostCSS plugin that uses Eik defined import map files to transform bare import specifiers to absolute URLs in @import rules

Downloads

1,115

Readme

postcss-import-map

PostCSS Eik plugin to support the use of import maps to map "bare" import specifiers in CSS @import rules.

Notes:

  • This plugin should probably be used as the first plugin of your list.
  • If you use postcss-import please read this.

Installation

$ npm install @eik/postcss-import-map

Usage

// dependencies
var fs = require('fs');
var postcss = require('postcss');
var eikImportMapPlugin = require('@eik/postcss-import-map');

// css to be processed
var css = fs.readFileSync('css/input.css', 'utf8');

// process css
postcss()
    .use(
        eikImportMapPlugin({
            imports: {
                'normalize.css':
                    'https://unpkg.com/normalize.css@8/normalize.css',
            },
        })
    )
    .process(css, {
        // `from` option is needed here
        from: 'css/input.css',
    })
    .then(function (result) {
        var output = result.css;

        console.log(output);
    });

css/input.css:

@import 'normalize.css';

body {
    background: black;
}

will give you:

@import 'https://unpkg.com/normalize.css@8/normalize.css';

body {
    background: black;
}

PostCSS Import Usage

If you're using postcss-import make sure you update the plugins option. postcss.config.js

module.exports = (ctx) => ({
    plugins: [
        require('@eik/postcss-import-map')(),
        require('postcss-import')({
            // It needs to be added here as well to ensure everything is mapped
            plugins: [require('@eik/postcss-import-map')],
        }),
    ],
});

Options

This plugin takes an import map as options:

| option | default | type | required | details | | ------- | -------------- | -------- | -------- | ----------------------------------------------------------- | | path | cwd/eik.json | string | false | Path to eik.json file. | | urls | [] | array | false | Array of import map URLs to fetch from. | | imports | {} | object | false | Mapping between "bare" import specifiers and absolute URLs. |

This module only cares about "bare" import specifies which map to absolute URLs in the import map. Any other import specifiers defined in the import map are ignored.

License

Copyright (c) 2020 Finn.no

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.