Multiple entry points with glob pattern / Ignore files and directories with leading underscore _ / Preserve directory structure
npm install --save-dev @sect/webpack-sweet-entry
- Multiple entry points with glob pattern.
- Ignore files and directories with leading underscore
_. - Preserve directory structure in
distdirectory. - Dual Package Support (CommonJS and ES Modules).
constwebpack=require('webpack');constpath=require('path');const{ WebpackSweetEntry }=require('@sect/webpack-sweet-entry');constsourcePath=path.join(__dirname,'src');constbuildPath=path.join(__dirname,'dist');module.exports=[{entry: WebpackSweetEntry(path.resolve(sourcePath,'assets/js/**/*.js*'),'js','js'),output: {path: path.resolve(buildPath,'assets/js'),filename: '[name].js',},module: {
...
}},{entry: WebpackSweetEntry(path.resolve(sourcePath,'assets/css/**/*.css'),'css','css'),output: {path: path.resolve(buildPath,'assets/css'),filename: '[name].css',},module: {
...
}}];importwebpackfrom'webpack';importpathfrom'path';import{fileURLToPath}from'url';import{dirname}from'path';import{WebpackSweetEntry}from'@sect/webpack-sweet-entry';const__filename=fileURLToPath(import.meta.url);const__dirname=dirname(__filename);constsourcePath=path.join(__dirname,'src');constbuildPath=path.join(__dirname,'dist');exportdefault[{entry: WebpackSweetEntry(path.resolve(sourcePath,'assets/js/**/*.js*'),'js','js'),output: {path: path.resolve(buildPath,'assets/js'),filename: '[name].js',},module: {
...
}},{entry: WebpackSweetEntry(path.resolve(sourcePath,'assets/css/**/*.css'),'css','css'),output: {path: path.resolve(buildPath,'assets/css'),filename: '[name].css',},module: {
...
}}];importwebpackfrom'webpack';importpathfrom'path';import{fileURLToPath}from'url';import{dirname}from'path';import{WebpackSweetEntry}from'@sect/webpack-sweet-entry';const__filename=fileURLToPath(import.meta.url);const__dirname=dirname(__filename);constsourcePath=path.join(__dirname,'src');constbuildPath=path.join(__dirname,'dist');constconfig: webpack.Configuration[]=[{entry: WebpackSweetEntry(path.resolve(sourcePath,'assets/js/**/*.js*'),'js','js'),output: {path: path.resolve(buildPath,'assets/js'),filename: '[name].js',},module: {
...
}},{entry: WebpackSweetEntry(path.resolve(sourcePath,'assets/css/**/*.css'),'css','css'),output: {path: path.resolve(buildPath,'assets/css'),filename: '[name].css',},module: {
...
}}];exportdefaultconfig;constconfig: webpack.Configuration[]=[{entry: WebpackSweetEntry(path.resolve(sourcePath,'assets/scripts/**/*.*s*'),['ts','js'],'scripts'),output: {
...
},module: {
...
}},
...
];WebpackSweetEntry(path,ext,parentdir);| arg | type | Description | Example |
|---|---|---|---|
| path | string | string[] | File path glob(s) | path.resolve(sourcePath, 'assets/js/**/*.js*') or [path.resolve(sourcePath, 'assets/js/**/*.js*'), '!**/a.js'] |
| ext | string | string[] | File extension | js or ['ts', 'js'] |
| parentdir | string | Parent Dirctory Name for files (The directory name where the tree starts) | js |
Returns object like the following.
{a: '/path/to/your/src/assets/js/a.js',b: '/path/to/your/src/assets/js/b.js','dir/e': '/path/to/your/src/assets/js/dir/e.js'}{a: '/path/to/your/src/assets/css/a.css',b: '/path/to/your/src/assets/css/b.css','dir/e': '/path/to/your/src/assets/css/dir/e.css'}.
├── dist
│ └── assets
│ ├── css
│ │ ├── a.css
│ │ ├── b.css
│ │ └── dir
│ │ └── e.css
│ └── js
│ ├── a.js
│ ├── b.js
│ └── dir
│ └── e.js
├── src
│ └── assets
│ ├── css
│ │ ├── a.css
│ │ ├── b.css
│ │ ├── _c.css
│ │ ├── _d.css
│ │ └── dir
│ │ ├── e.css
│ │ └── _f.css
│ └── js
│ ├── a.js
│ ├── b.js
│ ├── _c.js
│ ├── _d.js
│ ├── _modules
│ │ ├── a.js
│ │ └── b.js
│ └── dir
│ ├── e.js
│ └── _f.js
├── package-lock.json
├── package.json
└── webpack.config.js
$ npm uninstall webpack-sweet-entry
$ npm install --save-dev @sect/webpack-sweet-entry
- const WebpackSweetEntry = require('webpack-sweet-entry');+ const { WebpackSweetEntry } = require('@sect/webpack-sweet-entry');When you make a change that should be included in the next release:
- Create a feature branch
- Make your changes
- Add a changeset:
npm run changeset- Select the type of change (patch/minor/major)
- Provide a description of the change
- Commit the changeset file along with your changes
- Create a pull request
This project uses changesets for version management and releases.
Automated Release Workflow:
- When a PR with changesets is merged to master, a "Version Packages" PR is automatically created
- The Version Packages PR includes:
- Updated version numbers in package.json
- Updated CHANGELOG.md
- Removed changeset files
- When the Version Packages PR is merged:
- The package is automatically built
- Published to npm with provenance
- A GitHub release is created
Manual Testing:
# Create a test changeset
npm run changeset
# Preview version bump (without publishing)
npm run version-packages
# Build and test before release
npm run build
npm test
npm run lintSee CHANGELOG file.
✌️
A little project by @sectsect