webpack-entries-autodiscovery

Entries autodiscovery for webpack

Usage no npm install needed!

<script type="module">
  import webpackEntriesAutodiscovery from 'https://cdn.skypack.dev/webpack-entries-autodiscovery';
</script>

README

Webpack Entries Autodiscovery

This package adds abilty to autodiscover webpack entries.

Installing

npm install webpack-entries-autodiscovery --dev

Usage

In your webpack.config.js:

const {discoverEntries} = require('webpack-entries-autodiscovery');

module.exports = {
  entry: discoverEntries({
    basePath: __dirname,
    entriesDirName: 'assets/features', 
    entryFilename: 'entry',
    entryExtensions: ['js', 'ts']
  }) 
};

With such config, discoverer will count as entry every entry js or ts file in folder or subfolder of ./assets/features. Example output:

Webpack Entries Autodiscovery
=============================

Entries for /var/www/someproject
-----------------------------------------------

demo:                   /var/www/someproject/assets/features/demo/entry.js
cool-feature:           /var/www/someproject/assets/features/cool-feature/entry.ts
nested/cool-feature:    /var/www/someproject/assets/features/nested/cool-feature/entry.ts
styleguide:             /var/www/someproject/assets/features/styleguide/entry.ts
                                                                                                                        
[OK] 4 entries are discovered!                                                                                         

When no params is provided - defaults will be used:

{
    basePath: '',
    entriesDirName: 'src', 
    entryFilename: 'index',
    entryExtensions: ['js']
}