Dynamic entry points / Partial files with underscore / Keep Directory Structure for output
npm i webpack-sweet-entry --save-dev
- Helps Dynamic entry points
- Support Partial files (Files and Directories named with a leading underscore
_
is ignored.) - Keep Directory Structure for output
const webpack = require('webpack');
const path = require('path');
const WebpackSweetEntry = require('webpack-sweet-entry');
const sourcePath = path.join(__dirname, 'src');
const buildPath = 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: {
...
}
}
];
WebpackSweetEntry(path, ext, parentdir);
arg | type | Description | Example |
---|---|---|---|
path | string |
File path | path.resolve(sourcePath, 'assets/js/**/*.js*') |
ext | string |
File extension | js |
parentdir | string |
Parent Dirctory Name for files | js |
WebpackSweetEntry()
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
├── postcss.config.js
└── webpack.config.js
See CHANGELOG file.
- v1.1.0 - 💥 Minor changes: The
glob
package was bundled within this package. Removeglob()
in your webpack.config.js.
- Create an issue and describe your idea
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Publish the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Profit! ✅
See LICENSE file.