1.0.3 • Published 2 years ago
hoist-peers-webpack-resolve-plugin v1.0.3
Hoist-Peers-Webpack-Resolve-Plugin
use hoisting dep's peerDependencies even though already existing in dep's node_modules
English | 简体中文
Install
npm i hoist-peers-webpack-resolve-plugin --save-dev
Usage
using webpack.config.js
// webpack.config.js
// ...
const { HoistPeersWebpackResolvePlugin } = require('hoist-peers-webpack-resolve-plugin');
module.exports = {
// ...
resolve: {
// ...
plugins: [
// ...
new HoistPeersWebpackResolvePlugin({ deps: ['your-npm-link-dep-name'] })
]
},
// ...
}
using webpack-chain
// webpack.config.js
// ...
const Config = require('webpack-chain');
const { HoistPeersWebpackResolvePlugin } = require('hoist-peers-webpack-resolve-plugin');
// ...
const config = new Config();
// ...
config.resolve
.plugin('HoistPeersWebpackResolvePlugin')
.use(HoistPeersWebpackResolvePlugin, [{ deps: ['@apaas/common'] }]);
// ...
module.exports = config.toConfig();
Tips: more options see webpack-chain.
Options
deps
- type:
string[]
- required:
true
- desc: dependences's names which peers need to be force hoisted.
- examples:
new HoistPeersWebpackResolvePlugin({ deps: ['lodash'] });
options
- type:
object
- required:
false
- desc: polyfills for webpack v4. (only works in webpack v4)
- example:
new HoistPeersWebpackResolvePlugin({ deps: ['lodash'], { symlinks: true, modules: [path.join(__dirname, './node_modules')], roots: [path.join(__dirname)], } });
options.symlinks
- type:
boolean
- required:
true
(if in webpack v4) - desc: the same option of webpack config config.resolve.symlinks.
options.modules
- type:
string[]
- required:
true
(if in webpack v4) - desc: the same option of webpack config config.resolve.modules.
- tips: must be absolute path.
options.roots
- type:
string[]
- required:
true
(if in webpack v4) - desc: the same option of webpack config config.resolve.roots.
- tips: must be absolute path.