1.0.8 • Published 2 years ago

inject-imports-loader v1.0.8

Weekly downloads
12
License
MIT
Repository
github
Last release
2 years ago

npm node deps travis

npm i inject-imports-loader --save-dev

Inline

import 'inject-imports-loader?angular-mocks,lodash[]=reduce,lodash[]=transform~tf!./file.js';

Results in:

file.js

/*** IMPORTS FROM inject-imports-loader ***/
import "angular-mocks";
import angular from "angular";
import { reduce, transform as tf } from "lodash";

// ... (content of file.js)

Configuration

webpack.config.js

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /file\.js$/,
        use: {
          loader: 'inject-imports-loader',
          options: {
            'angular-mocks': true,
            'angular': 'angular',
            'lodash': ['reduce', 'transform~tf'],
          }
        }
      }
    ]
  }
  // ...
}

Results in:

file.js

/*** IMPORTS FROM inject-imports-loader ***/
import "angular-mocks";
import angular from "angular";
import { reduce, transform as tf } from "lodash";

// ... (content of file.js)

Similar loaders

This loader has similarities to the imports-loader, but it uses es6 import statements instead of require. If you want to inject constants or replace this with a custom value you should use the imports-loader instead (Or use both in combination).

3.0.0

2 years ago

1.0.8

3 years ago

2.0.2

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

2.0.1

3 years ago

2.0.0

4 years ago

1.0.4

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago