https://github.com/privatenumber/entry-file-plugin
Create an ESM entry-file in your Webpack build to consolidate entry-point exports
https://github.com/privatenumber/entry-file-plugin
entry file plugin webpack
Last synced: 3 months ago
JSON representation
Create an ESM entry-file in your Webpack build to consolidate entry-point exports
- Host: GitHub
- URL: https://github.com/privatenumber/entry-file-plugin
- Owner: privatenumber
- Created: 2021-08-07T06:22:52.000Z (almost 4 years ago)
- Default Branch: develop
- Last Pushed: 2021-08-10T23:08:46.000Z (almost 4 years ago)
- Last Synced: 2025-02-16T16:01:47.585Z (4 months ago)
- Topics: entry, file, plugin, webpack
- Language: TypeScript
- Homepage:
- Size: 93.8 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Create an ESM entry-file in your Webpack build to consolidate entry-point exports
Support this project by ⭐️ starring and sharing it. [Follow me](https://github.com/privatenumber) to see what other cool projects I'm working on! ❤️
## 🙋♂️ Why?
For consolidating exports from Webpack builds that emit multiple entry-points.A great use-case for this is Vue.js component builds that extract the CSS into a separate file. Even if the build bundles multiple components, by creating an entry-point that imports the CSS and re-exports the components, consuming applications can simply import from one path to get the appropriate styles.
## 🚀 Install
```sh
npm i -D entry-file-plugin
```## 🚦 Quick setup
In `webpack.config.js`:
```diff
+ const EntryFilePlugin = require('entry-file-plugin')module.exports = {
...,plugins: [
...,
+ new EntryFilePlugin({
+ imports: [...],
+ exports: [...]
+ })
]
}
```### Example
The following configuration:
```js
new EntryFilePlugin({
imports: [
'./styles.css',
],
exports: [
'./components.js',
],
})
```Creates an `index.js` file:
```js
import "./styles.css";
export * from "./components.js";
```## ⚙️ Options
### filename
Type: `string`Default: `index.js`
The entry file name.
### imports
Type: `string[]`An array of paths to import from.
### exports
Type:```ts
type Specifier = (string | {
name: string;
as?: string;
})[];type Exports = (string | {
from: string;
specifiers?: Specifier[];
})[];
```An array of paths and names to export from.
### omitSourcesNotFound
Type: `boolean`Default: `false`
Whether to omit import/export statements for relative paths that could not be resolved. If `false`, a warning will be emitted for unresolvable import/exports.
## 👨👩👧 Related
- [rollup-plugin-aggregate-exports](https://github.com/privatenumber/rollup-plugin-aggregate-exports) - Similar plugin for Rollup