All Projects → sanjsanj → webpack-entry-plus

sanjsanj / webpack-entry-plus

Licence: MIT license
Generate dynamic webpack bundle output names from known or unknown entry files

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to webpack-entry-plus

venusscript
A dynamic, interpreted, scripting language written in Java.
Stars: ✭ 17 (-29.17%)
Mutual labels:  dynamic
nextjs-redirect
HOC to redirect to any URL in NextJS both in client and server
Stars: ✭ 144 (+500%)
Mutual labels:  dynamic
dynamic-app
Dynamic Forms Builder are reusable and make building large-scale applications easier (Easy Peasy)
Stars: ✭ 15 (-37.5%)
Mutual labels:  dynamic
eruda-webpack-plugin
A webpack plugin of eruda to help you develop mobile app
Stars: ✭ 56 (+133.33%)
Mutual labels:  webpack3
dynamic-threadpool
📌 强大的动态线程池框架,附带监控报警功能。支持 JDK、Tomcat、Jetty、Undertow 线程池;Dubbo、Dubbox、RabbitMQ、RocketMQ、Hystrix 消费线程池(更多框架线程池还在适配中)。内置两种使用模式:轻量级依赖配置中心以及无中间件依赖版本。
Stars: ✭ 3,609 (+14937.5%)
Mutual labels:  dynamic
ConnectedProperties
Dynamically attach properties to (almost) any object instance.
Stars: ✭ 38 (+58.33%)
Mutual labels:  dynamic
github-readme-activity-graph
A dynamically generated activity graph to show your GitHub activities of last 31 days.
Stars: ✭ 1,029 (+4187.5%)
Mutual labels:  dynamic
readme-components
Cards for your readme
Stars: ✭ 44 (+83.33%)
Mutual labels:  dynamic
scrapy helper
Dynamic configurable crawl (动态可配置化爬虫)
Stars: ✭ 84 (+250%)
Mutual labels:  dynamic
webpack-starter
A basic setup of webpack goodness. Packed with common fronted workflow to help ease development headache. Ready with development and production config. Feel free to fork and enhance. Have an Awesome frontend coding!
Stars: ✭ 22 (-8.33%)
Mutual labels:  webpack3
webpack-boilerplate
Webpack 4 boilerplate (babel, eslint, prettier, jest, sass, postcss, hmr, browsersync)
Stars: ✭ 33 (+37.5%)
Mutual labels:  webpack3
Equinox
🌇 🌃 Create dynamic wallpapers for macOS.
Stars: ✭ 737 (+2970.83%)
Mutual labels:  dynamic
Build-Former
This is a library for building forms dynamically in Android.
Stars: ✭ 20 (-16.67%)
Mutual labels:  dynamic
laravel-livewire-modals
Dynamic Laravel Livewire Bootstrap modals.
Stars: ✭ 63 (+162.5%)
Mutual labels:  dynamic
action-dynamic-readme
~ Dynamic ReadME Generator ~
Stars: ✭ 29 (+20.83%)
Mutual labels:  dynamic
rapp
Cross-platform entry point library
Stars: ✭ 57 (+137.5%)
Mutual labels:  entry
joineRML
R package for fitting joint models to time-to-event data and multivariate longitudinal data
Stars: ✭ 24 (+0%)
Mutual labels:  dynamic
1pt
A URL shortener with protection against malicious redirects
Stars: ✭ 20 (-16.67%)
Mutual labels:  dynamic
NSL
Implementation for <Neural Similarity Learning> in NeurIPS'19.
Stars: ✭ 33 (+37.5%)
Mutual labels:  dynamic
Kendo.DynamicLinqCore
KendoNET.DynamicLinq implements server paging, filtering, sorting, grouping, and aggregating to Kendo UI via Dynamic Linq for .Net Core App(1.x ~ 3.x).
Stars: ✭ 36 (+50%)
Mutual labels:  dynamic

webpack-entry-plus

Generate dynamic webpack bundle output names from wildcarded entry files.

NPM

Code Size Build Status codecov

Why?

This package solves the problem of not knowing (or wanting to hardcode) all of our output bundles' names. Particularly useful if you're building a CMS-based architecture or multi-page app. Read more about it here.

Install

Install with npm:

npm install --save-dev webpack-entry-plus

API

Must be passed an argument which is an [ Array of { Objects } ] that comply to this schema:

[
  {
    entryFiles: Array of String(s),
    outputName: String, or Function that returns a String,
  },
]

If we want to use wildcard matchers to include unknown files, use the included glob package like so:

// import glob
const glob = require('glob');

[
  {
    entryFiles: glob.sync('./Folder1/*.js'),
    outputName: String or Function that returns String,
  },
]

If we want to create a dynamic output name, pass a function in to outputName that takes one argument and returns the [name] we want to use. The argument, (item) in this example, is the filepath for the file being processed:

[
  {
    entryFiles: Array of String(s),
    outputName(item) {
      return item.replace('unwanted text', 'text');
      // or any other string transform we want
      // must return a string which will become the [name] in our output
    },
  },
]
  • If we pass a String in to outputName it will bundle all the entryFiles in to one.

  • If we pass a Function in to outputName it will process each entry file in to it's own bundle, using the returned value of outputName(entryFile[singular]) as the [name] in webpack's output object.

Example Usage

// webpack.config.js
// First `import` or `require` this package, and glob for wildcard matching, e.g:

const entryPlus = require('webpack-entry-plus');
const glob = require('glob');

// Then create an Array of Objects containing our entry files:

const entryFiles = [
  {
    entryFiles: ['file1.js'],
    outputName: 'bundle1',
  },
  {
    entryFiles: ['file2.js', 'file3.js'],
    outputName: 'bundle2',
  },
  {
    entryFiles: ['react', 'react-dom'],  // node modules work too
    outputName: 'react',
  },
  {
    entryFiles: glob.sync('./core/*.js'),
    outputName: 'core',
  },
  {
    entryFiles: glob.sync('./Folder1/**/*-entry.js'),
    outputName(item) {
      return item.replace('Folder1/', '../');
    },
  },
];

Then pass the function in to the `entry` point of our config:

module.exports = {
  entry: entryPlus(entryFiles),

  output: {
    filename: '[name].js',
  },

  ...
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].