webpack-sweet-entry

Dynamic entry points / Partial files / Keep Directory Structure for webpack

This npm package 'webpack-sweet-entry' has moved to a scoped package. The new repository is available @sect/webpack-sweet-entry. To install the new package, run npm install --save-dev @sect/webpack-sweet-entry
Last updated 7 months ago by sect .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install webpack-sweet-entry 
SYNC missed versions from official npm registry.

webpack sweet entry

CircleCI npm version MIT license

NPM

Dynamic entry points / Partial files with underscore / Keep Directory Structure for output

Installation

npm i webpack-sweet-entry --save-dev

Feature

  • Helps Dynamic entry points with wildcards
  • Support Partial files (Files and Directories named with a leading underscore _ is ignored.)
  • Keep Directory Structure for output

Usage Example

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: {
      ...
    }
  }
];

Multiple(Mixed) extentions

module.exports = [
  {
    entry: WebpackSweetEntry(path.resolve(sourcePath, 'assets/scripts/**/*.*s*'), ['ts', 'js'], 'scripts'),
    output: {
      path: path.resolve(buildPath, 'assets/js'),
      filename: '[name].js',
    },
    module: {
      ...
    }
  },
  ...
];

function

WebpackSweetEntry(path, ext, parentdir);
arg type Description Example
path string File path path.resolve(sourcePath, 'assets/js/**/*.js*')
ext string | array File extension js or ['ts', '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'
}

Result

.
├── 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

Change log

See CHANGELOG file.

Contributing

  1. Create an issue and describe your idea
  2. Fork it
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Publish the branch (git push origin my-new-feature)
  6. Create a new Pull Request
  7. Profit! :white_check_mark:

License

See LICENSE file.

Current Tags

  • 1.2.0                                ...           latest (7 months ago)

16 Versions

  • 1.2.0 [deprecated]           ...           7 months ago
  • 1.1.12 [deprecated]           ...           9 months ago
  • 1.1.11 [deprecated]           ...           a year ago
  • 1.1.10 [deprecated]           ...           a year ago
  • 1.1.9 [deprecated]           ...           a year ago
  • 1.1.8 [deprecated]           ...           a year ago
  • 1.1.7 [deprecated]           ...           a year ago
  • 1.1.6 [deprecated]           ...           2 years ago
  • 1.1.5 [deprecated]           ...           2 years ago
  • 1.1.4 [deprecated]           ...           2 years ago
  • 1.1.3 [deprecated]           ...           2 years ago
  • 1.1.2 [deprecated]           ...           2 years ago
  • 1.1.1 [deprecated]           ...           2 years ago
  • 1.1.0 [deprecated]           ...           2 years ago
  • 1.0.1 [deprecated]           ...           2 years ago
  • 1.0.0 [deprecated]           ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 17
Dependencies (3)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |