@wildpeaks/glob-webpack-plugin
Webpack config to define entry with a glob
Last updated 2 months ago by cecilemuller .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @wildpeaks/glob-webpack-plugin 
SYNC missed versions from official npm registry.

Glob Webpack Plugin

Greenkeeper badge

Webpack 4.x plugin to define entry using a glob.

It also updates the list of entries in --watch mode, without having to restart Webpack.


Quickstart

Install:

npm install @wildpeaks/glob-webpack-plugin

Then use it in your webpack.config.js:

const GlobPlugin = require('@wildpeaks/glob-webpack-plugin');

module.exports = {
	target: 'web',
	plugins: [
		new GlobPlugin({
			entries: './src/*.js'
		})
	]
};

Entry identifiers

By default, it uses the filename as Entry Name.

So, for example, ./src/app1.js would produce this entry:

{
  "app1": "./src/app1.js"
}

You can provide a function to provide a custom name:

const {basename} = require('path');
const GlobPlugin = require('@wildpeaks/glob-webpack-plugin');

module.exports = {
	target: 'web',
	plugins: [
		new GlobPlugin({
			entries: './src/*.js',
			entriesMap: filepath => 'bundle-' + basename(filepath, '.js')
		})
	]
};

In this example, ./src/app1.js would produce this entry:

{
  "bundle-app1": "./src/app1.js"
}

Polyfills

Property polyfills prepends modules to every entry:

const {basename} = require('path');
const GlobPlugin = require('@wildpeaks/glob-webpack-plugin');

module.exports = {
	target: 'web',
	plugins: [
		new GlobPlugin({
			entries: './src/*.js',
			polyfills: [
				'polyfill-module',
				'./src/local-polyfill.js',
				'./src/reset.css'
			]
		})
	]
};

Known limitations

It currently overwrites entry (because it's meant to replace), so if you need multiple globs, your webpack.config.js can export an array of Webpack configs, each with its own glob.

On Windows, merely renaming or deleting an entry doesn't trigger a rebuild, but creating or updating files do.

Current Tags

  • 2.4.1                                ...           latest (2 months ago)

8 Versions

  • 2.4.1                                ...           2 months ago
  • 2.4.0                                ...           3 months ago
  • 2.3.0                                ...           4 months ago
  • 2.2.0                                ...           8 months ago
  • 2.1.0                                ...           8 months ago
  • 2.0.0                                ...           9 months ago
  • 1.0.0                                ...           10 months ago
  • 1.0.0-alpha2                                ...           10 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |