0.1.4 • Published 3 years ago

single-spa-generate-imports-webpack v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

single-spa-generate-imports-webpack

A webpack plugin which allow to generate importmap.json with output filename for single-spa application on compile.

Installation

npm install --save-dev single-spa-generate-imports-webpack

Usage

In config file:

const SingleSpaGenerateImports = require('single-spa-generate-imports-webpack');
// ...
  module: {
    plugins: [
      new SingleSpaGenerateImports({
        packageName: '@hulk/core', // required
        staticPath: 'http://some.url/point/to/your/import/path', // default from env process.env.STATIC_PATH
        filename: 'importmap.json'
      }),
    ]
  },
// ...

Generate file:

// dist/importmap.json
{
  imports: {
    "@hulk/core": "http://some.url/point/to/your/import/path/hulk-core.<hash>.js"
  }
}

Multi Entry points:

const SingleSpaGenerateImports = require('single-spa-generate-imports-webpack');
// ...
  module: {
    entry: {
      'hulk-styleguide': `./src/main.ts`,
      'styles': `./src/styles.ts`,
    }
    ...
    plugins: [
      new SingleSpaGenerateImports({
        packageName: {
          'hulk-styleguide': '@hulk/styleguide',
          'styles': '@hulk/styleguide/styles',
          ...
        }
        ...
      }),
    ]
  },
// ...

Generate file multi imports:

// dist/importmap.json
{
  imports: {
    "@hulk/styleguide": "http://some.url/point/to/your/import/path/hulk-styleguide.<hash>.js"
    "@hulk/styleguide/styles": "http://some.url/point/to/your/import/path/styles.<hash>.js"
    ...
  }
}
0.1.4

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.3

3 years ago

0.1.0

3 years ago