2.1.1 • Published 6 years ago

webpack-plugin-inverted-index-generator v2.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

what is this ?

this plugin will search all files of specified types in your specified folder, and exports them via an automatically generated inverted index file. format of the index file will looks like below: example

usage

since now on, you can import webpack modules without necessary to specify their paths. for example: Assume we want to import a module called--'exampleModule' whose path is './modules/variousPaths-a/variouspaths-b/exampleModule'.

With the original method, we can only do this like this:

import exampleModule from './modules/variousPaths-a/variouspaths-b/exampleModule'

After we used this plugin, we can import that module from './modules/index.js':

import {exampleModule} from './modules'

notice: namesake conflicts !

This plugin yet can not handle namesake conflicts, so if there has same name modules in your specified directory, you should not import them via the index file that generated by this plugin. Otherwise, it will lead to unexpected bugs.
as a fallback solution, you have to import namesake modules via specify their respective paths.

installation guide

1.download

npm i --save-dev webpack-plugin-inverted-index-generator

2.configure webpack.config.js

note: if there has no webpack.config.js file in your project root, you need to create one at first.

const ResourceIndex = require('webpack-plugin-inverted-index-generator')

module.exports = {
  plugins: [
    new ResourceIndex({ // configuration for example:
      rules: { // required
        'specified-directory': ['specified-fileType'], // current working directory is your project root.
        './src/components': ['.vue', '.custom-extension.js'],
        './src/assets': [ '.svg', '.meta.txt', 'index.js'] // fileType could be a filename extension or a filename.
      },
      debug: true // optional
    })
  ]
}
2.1.1

6 years ago

2.1.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago