Skip to content

Commit 138adfd

Browse files
BREAKING: webpack-cli v3 (#448)
* chore(monorepo): move to lerna * chore(monorepo): use commands as normal instead of package * fix(revert): packagejson * chore(monorepo): prune files and update eslint rules * chore(monorepo): fix the no-missing-require error * chore(monorepo): fix typo * chore(monorepo): fix typo * chore(monorepo): prune package json * chore(monorepo): merge package lock json * chore(monorepo): updated package.json * chore(monorepo): fix plugin package.json * chore(cli): move to lerna and scoped packages (#434) * fix(loader,plugin): fix generators path bug * cli(refactor): improve folder structure (#371) * cli(refactor): improve folder structure * chore(linting): fix linter errors * cli(filepath): use local import instead * cli(migrate): refactor error handling * chore(review): fix review comments * chore(review): fix review comments * chore(review): fix review comments * chore(version): v.2.0.14 * Add break as commit type and listed the type of commit in the documentation (#379) * docs(commits): listed the list of type of commits available * cli(init): mode support to config (#364) * cli(init): mode support to config * cli(bugfix): Allow mode "none" in CLI (#381) * cli(init): use extractMiniCSSPlugin (#363) * cli(init): skip redundant question * cli(init): use mini-css-extract-plugin * Retrieve information for CLI option from webpack schema options file (#392) * cli(refactor): fetch available modes directly from webpack options schema * cli(refactor): Retrieve information from webpackOptionSchema * cli(add): write configuration to yeoman file (#348) * misc(add): variable parity, prettify * cli(add): write config to yeoman-rc * misc(add): improve generator questions * fix(init): output file name for single output (#403) improved output filename * cli(migrate): Update migration question (#402) * cli(init): webpack4 ready (#356) * cli(init): webpack4 ready * cli(init): remove unused variable, still @next on etwp * cli(init): Allow to use default entry in `init` * cli(init): Fix typo in comment * cli(init): Optimization transform and tests * cli(init): Fix non-optimized option for splitChunks * cli(init): Add cachingGroup per entry, don't show name in prod * cli(init): Add cachingGroup's defaults, fix entry * cli(init): Add a link to where the defaults live * cli(init): Remove default caching group definition from example * Add NoEmitOnErrorsPlugin transformation (#399) * ast(migrate): handle no emit on error * ast(migrate): handle module concatenation and named modules * ast(migrate): handle module concatenation and named modules * fix(ast): checks validity of an identifier (#360) added test cases for validate identifier * cli(entry): quotes sanitization (#337) * chore: minor doc fixes * cli(entry): quotes sanitization * tests(entry): add test case for double quotes * tests(entry): update snapshots * misc(utils): entry - variable parity * misc(prop-types): sort * cli(entry): multiple entries quotes sanitization * chore(versioning): v 2.0.15 * chore(versioning): push new package version * cli(fix): remove reference to specific version during migration (#410) * fix: remove reference to specific version during migration * fix: rephrase update message * chore(docs): updated old references to the extract text plugin (#412) * chore(dev): added break to the list of type of commit * init(fix): removed references to extract text plugin * fix(commit): rollback * cli(migration): update UglifyJS transformation (#416) * cli(migration): Update UglifyJS migration file to fit webpack4 configuration * cli(migration): Add cases where require variable does not need to exist * cli(migration): Add transformation for usage of webpack.otimization.UglifyPlugin * cli(tests): Update test snapshots after updating transformation * cli(fix): fix expressionContent being null * cli(refactor): remove plugins array if empty Created function on ast-utils so every other transformation can use this. * tests: add tests for new ast-utils method * fix: fix test names and jsdoc * fix: update maxSize for utils folder * ast(cli): Recursively parse AST (#341) * ast(refactor): wip refactor * ast(refactor): wip refactor * ast(init): refactor * test(refactor): refactor test suite * tests(define): swap args * ast(parsing): refactor stuff * ast(init): refactor * ast(init): refactor tests * chore(tests): remove some unneeded tests * chore(pkg): update package.json * chore(project): clear up project structure * chore(cli): remove unneded files * chore(git): add gitignore to yeoman file * chore(deps): update pkg.json * tests(snapshots): update snapshots * tests(jest): use empty module for snapshots * tests(snap): only test one prop * chore(publishing): add semantic-release (#415) * chore(release): [WIP] add semantic-release * test(ci): wip * test(ci): add node versions * test(ci): remove extra test * tests(ci): revise * tests(ci): only push to npm on master * tests(ci): use matrix on jobs * tests(ci): revise * tests(ci): update * tests(ci): test * tests(ci): test * tests(ci): p * tests(ci): update travis.yml * chore(release): revise travis * misc(yeoman): update yeoman * chore(travis): revise travis * misc(travis): revise travis.yml * chore(travis): remove redundant code * chore(pkg): add keywords * 2.1.1 * 2.1.2 * cli(cmds): revise yargs command (#422) * use yargs.command instead of yargs.option for sub-commands * cli(node): Add node flags to CLI (#377) * feat: add support for node flags * tests: Fix node-flags test * misc: Fix test failing due to not-found webpack-cli * misc: remove comment * misc: refactor removing unecessary args * tests: add more tests to prevent argument collision * cli(cmds): remove strict * fix(node): remove node option for now * chore(lerna): refactor * chore(lerna): refactor * chore(refactor): refactor stuff * chore(package): update pkg.lock * chore(templates): Update issue templates (#432) Adds fancy templates * ast(init): add topScope prop * ast(merge): re-add merge prop * cli(lerna): refactor * chore(lerna): refactor * chore(lerna): update * chore(lint): revise * chore(refactor): refactor * chore(tests): use lerna for tests * chore(travis): don't cache me outside * chore(pkg): remove prefer global * chore(release): v.2.1.3 * chore(package.lock): update pkg.lock * fix(loader,plugin): fix generators path bug * chore(version): v.2.0.14 * Add break as commit type and listed the type of commit in the documentation (#379) * docs(commits): listed the list of type of commits available * cli(bugfix): Allow mode "none" in CLI (#381) * cli(init): use extractMiniCSSPlugin (#363) * cli(init): skip redundant question * cli(init): use mini-css-extract-plugin * Retrieve information for CLI option from webpack schema options file (#392) * cli(refactor): fetch available modes directly from webpack options schema * cli(refactor): Retrieve information from webpackOptionSchema * cli(add): write configuration to yeoman file (#348) * misc(add): variable parity, prettify * cli(add): write config to yeoman-rc * misc(add): improve generator questions * fix(init): output file name for single output (#403) improved output filename * cli(migrate): Update migration question (#402) * fix(ast): checks validity of an identifier (#360) added test cases for validate identifier * chore(versioning): v 2.0.15 * chore(versioning): push new package version * cli(fix): remove reference to specific version during migration (#410) * fix: remove reference to specific version during migration * fix: rephrase update message * chore(docs): updated old references to the extract text plugin (#412) * chore(dev): added break to the list of type of commit * init(fix): removed references to extract text plugin * fix(commit): rollback * misc(yeoman): update yeoman * cli(cmds): revise yargs command (#422) * use yargs.command instead of yargs.option for sub-commands * cli(node): Add node flags to CLI (#377) * feat: add support for node flags * tests: Fix node-flags test * misc: Fix test failing due to not-found webpack-cli * misc: remove comment * misc: refactor removing unecessary args * tests: add more tests to prevent argument collision * cli(cmds): remove strict * fix(node): remove node option for now * chore(templates): Update issue templates (#432) Adds fancy templates * cli(lerna): refactor * chore(lerna): refactor * chore(pkg): remove prefer global * chore(travis): Add encrypted private ssh key * fix(pkg): test auto setup * cli(init): revise installation steps (#441) * cli(init): revise installation steps * chore(formatting): format code * cli(tests): refactor tests * chore(travis): run lockfile cmds on tests (#444) * Update dependencies to enable Greenkeeper 🌴 (#443) chore(greenkeeper): Update dependencies to enable Greenkeeper 🌴 * chore(docs): update readme * chore(travis): add Node.js 10 (#425) * chore(travis): move npm ci to install task (#424) * chore(travis): move npm ci to install task * chore: trigger new build * chore: upgrade Node.js for Appveyor to 8 * chore: remove redundanct npm install command * chore(linting): resolve linter errors * chore(linting): fix linting errors * chore(linting): resolve linting * chore(linting): resolve linting * chore(scaffold): move addons to scaffold * chore(scaffold): fix linting errors * cli(prompt): initial comment for prompt file * cli(prompt): wip * fix(monorepo): fix lint errors * fix(monorepo): fix cross spawn versions * fix(monorepo): update lock files * fix(monorepo): fix versions in pacakges * chore(rebase): refactor stuff * cli(pkgs): re-add entries * chore(v): revise pkg * v0.0.1 * chore(v): revise some deps * v0.0.2 * v0.0.3 * chore(v): back to v1 * v0.0.2 * v0.0.3 * v0.0.4 * chore(deps): update deps * chore(prompt): revise prompt cmd * v0.0.5 * cli(path): resolve better * v0.0.6 * chore(v.6): update init * chore(pkg): v.6 on next * chore(monorepo): add bootstrap to run chore(monorepo): add bootstrap to ci * chore(monorepo): fix appveyor build * chore(monorepo): fix appveyor build * chore(monorepo): add eslint-plugin-prettier * chore(monorepo): fix appveyor build chore(monorepo): fix appveyor build chore(monorepo): add eslint-plugin-prettier chore(monorepo): use nohoist * chore(monorepo): fix versions and use clean bootstrap * chore(monorepo): add rimraf globally chore(monorepo): revert back * chore(monorepo): fix windows build * cli(color): don't use color on non-tty (#452) * Added yarn lock file to gitignore (#455) * chore(next): dev version bump * chore(monorepo): fix windows build * cli(symlinks): Fix paths (#453) * cli(symlinks): fix symlinks * chore(linting): resolve linting errors * chore(rebase): remove old file * cli(init): Better defaults (#451) * cli(init): set default generator name * cli(init): better defaults * chore(rebase): remove old commit * cli(init): fix broken ast and merge scaffolds * chore(docs): better defaults * chore(lint): fix linting errors * chore(deps): remove path from dep installation * chore(resolve): resolve conflicts * fix(vulnerabilities): vulnerabilities patch for v3 (#460) * chore(dependencies): fix vulnerabilities * misc(scripts): update clean:all script * chore(dependencies): fix vulnerabilities * tests(parser): fix recursive-tests signature (#470) * chore(deps): add lerna * tests(coverage): fix coverage (#473) * test(coverage): fix coverage * test(binTestCases): run bintestcases on upper-repo * tests(travis): add node 10 * tests(cov): use regular nyc on tests * chore(lockfile): update pkglock * chore(semantic): configure plugins (#475) * fix(cli): show help flag when defaults fail (#466) * fixed test cases * remove unwanted console * fix(254) - addressed PR comments * fix(254) - added requested changes at right place * fix(254) - exit after error exit webpack if defaults are not found fix test cases for no options * fix: require chalk * refactor - addressed PR comments * refactor - addressed PR comments * refactor : remove unwanted keywords * chore(review): format * tests(no-options): refactor tests * ast(parser): add (#456) * ast(parser): add, update, remove - literal node support * ast(parser): add command * ast(util): update property, early exit * tests(add): resursive add ast * tests(add): update recursive parser snaps * misc(conflicts): resolve conflicts * tests(parser): update tests, inputs * chore(review): fix some things * ast(utils): add ast-path safe traverse and type support * ast(utils): merge update property with add property * tests(ast): add tests for safe traversals * misc(fixes): review comments * tests(ast): add tests for addProperty * misc(fixes): review comments * misc(fixes): review comments * misc(fixes): review comments * cli(add): re-add add command
1 parent 03c1969 commit 138adfd

File tree

331 files changed

+38467
-30903
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

331 files changed

+38467
-30903
lines changed

.appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ build: off
1313
install:
1414
- ps: Install-Product node $env:nodejs_version $env:platform
1515
- npm i -g npm
16+
- npm i
1617
- npm ci
1718
- npm install --global codecov
1819
- npm install eslint-plugin-node@latest --save-dev

.eslintrc.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,16 @@ module.exports = {
6060
"node/no-missing-require": [
6161
"error",
6262
{
63+
"resolvePaths": ["./packages"],
6364
"allowModules": [
64-
"webpack"
65+
"webpack",
66+
"@webpack-cli/generators",
67+
"@webpack-cli/init",
68+
"@webpack-cli/migrate",
69+
"@webpack-cli/utils",
70+
"@webpack-cli/generate-loader",
71+
"@webpack-cli/generate-plugin",
72+
"@webpack-cli/webpack-scaffold"
6573
]
6674
}
6775
],
@@ -71,7 +79,27 @@ module.exports = {
7179
{
7280
"allowModules": [
7381
"webpack",
74-
"webpack-dev-server"
82+
"webpack-dev-server",
83+
"@webpack-cli/generators",
84+
"@webpack-cli/init",
85+
"@webpack-cli/migrate",
86+
"@webpack-cli/utils",
87+
"@webpack-cli/generate-loader",
88+
"@webpack-cli/generate-plugin",
89+
"@webpack-cli/webpack-scaffold"
90+
]
91+
}
92+
],
93+
"node/no-extraneous-require": [
94+
"error",
95+
{
96+
"allowModules": [
97+
"@webpack-cli/migrate",
98+
"@webpack-cli/generators",
99+
"@webpack-cli/utils",
100+
"@webpack-cli/generate-loader",
101+
"@webpack-cli/generate-plugin",
102+
"@webpack-cli/webpack-scaffold"
75103
]
76104
}
77105
],

.gitignore

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ npm-debug.*
1919
yarn-error.log
2020

2121
# Jest Coverage
22-
/coverage
23-
/.nyc_output
22+
coverage
23+
.nyc_output
2424

2525
# Test Compilation
2626
test/js/*
2727

28+
# lerna log
29+
lerna-debug.log
30+
2831
# Yeoman file
29-
.yo-rc.json
32+
.yo-rc.json
33+
34+
# Yarn lock file
35+
yarn.lock

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ notifications:
33
email: false
44
language: node_js
55
node_js:
6+
- "10"
67
- "8"
78
- "7"
89
- "6"
@@ -49,6 +50,7 @@ install:
4950
- npm install -g codecov
5051
- npm install -g eslint
5152
- npm install -g greenkeeper-lockfile@1
53+
- lerna bootstrap
5254

5355
before_script: greenkeeper-lockfile-update
5456
after_script: greenkeeper-lockfile-upload
@@ -60,4 +62,6 @@ jobs:
6062
- stage: NPM release
6163
if: branch = master
6264
node_js: "lts/*"
63-
script: npm run travis-deploy-once "npm run semantic-release"
65+
script:
66+
- npm run changelog
67+
- npm run travis-deploy-once "npm run semantic-release"

INIT.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ What we are meaning here, is if you want to provide your bundle a single or mult
1414

1515
This answers to the output directory of your application. The output directory is where servers or your `index.html` will read the generated bundle from.
1616

17-
3. `Are you going to use this in production? (Y/n)`
18-
19-
If you answer `Yes` to this, we add [`MinCssExtractPlugin`](https://github.com/webpack-contrib/mini-css-extract-plugin) to your project. This means that your style files will be separated in production from the bundles where they are used. If you answer `No`, we will not use the plugin, and `Question 6` will be ignored by default.
20-
2117
4. `Will you be using ES2015? (Y/n)`
2218

2319
If you answer `Yes` to this question, we will add [`ES2015`](https://babeljs.io/learn-es2015/) to your webpack configuration, which will allow you to use modern JavaScript in your project.
@@ -29,8 +25,4 @@ If you use any sort of style in your project, such as [`.less`](http://lesscss.o
2925
6. `If you want to bundle your CSS files, what will you name the bundle? (press
3026
enter to skip)`
3127

32-
If you answered `Yes` to `Question 3`, this will be enabled. The default value for your generated CSS file is `style.[contentHash].css`, which will collect all your `.less`, `.scss` or `.css` into one file. This will make your build faster in production.
33-
34-
7. `Name your 'webpack.[name].js?' [default: 'prod/config']`
35-
36-
If you answered `Yes` to `Question 3`, the default name of your configuration will be `webpack.prod.js`, otherwise it will be `webpack.config.js` if you don't answer. Other good options to answer to this question is: `dev`, `base`, `production` or `development`.
28+
If you indicate based on previous questions that you are using production, this will be enabled. The default value for your generated CSS file is `style.[contentHash].css`, which will collect all your `.less`, `.scss` or `.css` into one file. This will make your build faster in production.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The `migrate` feature eases the transition from [version 1](http://webpack.githu
2929

3030
The `init` feature allows users to get started with webpack, fast. Through scaffolding, people can create their own configuration in order to faster initialize new projects for various of use cases.
3131

32-
`webpack-cli init webpack-addons-<package>`
32+
`webpack-cli init webpack-scaffold-<package>`
3333

3434
[Read more about scaffolding](SCAFFOLDING.md)
3535

SCAFFOLDING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ Before writing a `webpack-cli` scaffold, think about what you're trying to achie
88

99
`webpack-cli` offers an experience that is interactive and you can prompt users for questions (like, "What is your entry point?") to help customize the output accordingly.
1010

11-
## webpack-addons
11+
## webpack-scaffold
1212

13-
[`webpack-addons`](https://github.com/webpack-contrib/webpack-addons) is a utility suite for creating addons. It contains functions that could be of use for creating an addon yourself.
13+
`webpack-scaffold` is a utility suite for creating addons. It contains functions that could be of use for creating an addon yourself.
1414

15-
## webpack-addons-yourpackage
15+
## webpack-scaffold-yourpackage
1616

17-
In order for `webpack-cli` to compile your package, it must be available on npm or on your local filesystem. If you are curious about how you can create your very own `addon`, please read [How do I compose a
18-
webpack-addon?](https://github.com/ev1stensberg/webpack-addons-demo).
17+
In order for `webpack-cli` to compile your package, it must be available on npm or on your local filesystem. If you are curious about how you can create your very own `scaffold`, please read [How do I compose a
18+
webpack-addon?](https://github.com/ev1stensberg/webpack-scaffold-demo).
1919

20-
If the package is on npm, its name must have a prefix of `webpack-addons`.
20+
If the package is on npm, its name must have a prefix of `webpack-scaffold`.
2121

2222
If the package is on your local filesystem, it can be named whatever you want. Pass the path to the package.
2323

bin/webpack.js renamed to bin/cli.js

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,24 @@
1515
}
1616

1717
require("v8-compile-cache");
18+
19+
// try local module, fallback to global
20+
try {
21+
require.resolve("webpack");
22+
process.webpackModule = require("webpack");
23+
} catch (err) {
24+
const globalPathToWebpack = require("global-modules-path").getPath(
25+
"webpack"
26+
);
27+
process.webpackModule = require(globalPathToWebpack);
28+
}
1829
const ErrorHelpers = require("./errorHelpers");
1930

2031
const NON_COMPILATION_ARGS = [
2132
"init",
2233
"migrate",
23-
/*
2434
"add",
35+
/*
2536
"remove",
2637
"update",
2738
"make",
@@ -41,9 +52,7 @@
4152
});
4253

4354
if (NON_COMPILATION_CMD) {
44-
// eslint-disable-next-line
45-
require("../lib/index")(NON_COMPILATION_CMD, process.argv);
46-
return;
55+
return require("./prompt-command")(NON_COMPILATION_CMD, ...process.argv);
4756
}
4857

4958
const yargs = require("yargs").usage(`webpack-cli ${
@@ -81,7 +90,9 @@ For more information, see https://webpack.js.org/api/cli/.`);
8190
type: "boolean",
8291
alias: "colors",
8392
default: function supportsColor() {
84-
return require("supports-color").supportsColor;
93+
if (process.stdout.isTTY === true) {
94+
return require("supports-color").supportsColor;
95+
}
8596
},
8697
group: DISPLAY_GROUP,
8798
describe: "Enables/Disables colors on the console"
@@ -287,7 +298,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
287298
}
288299

289300
const firstOptions = [].concat(options)[0];
290-
const statsPresetToOptions = require("webpack").Stats.presetToOptions;
301+
const statsPresetToOptions = process.webpackModule.Stats.presetToOptions;
291302

292303
let outputOptions = options.stats;
293304
if (
@@ -323,7 +334,10 @@ For more information, see https://webpack.js.org/api/cli/.`);
323334
}
324335
});
325336

326-
if (typeof outputOptions.colors === "undefined")
337+
if (
338+
typeof outputOptions.colors === "undefined" &&
339+
process.stdout.isTTY === true
340+
)
327341
outputOptions.colors = require("supports-color").stdout;
328342

329343
ifArg("sort-modules-by", function(value) {
@@ -429,7 +443,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
429443
outputOptions.buildDelimiter = value;
430444
});
431445

432-
const webpack = require("webpack");
446+
const webpack = process.webpackModule;
433447

434448
let lastHash = null;
435449
let compiler;
@@ -450,7 +464,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
450464
}
451465

452466
if (argv.progress) {
453-
const ProgressPlugin = require("webpack").ProgressPlugin;
467+
const ProgressPlugin = process.webpackModule.ProgressPlugin;
454468
new ProgressPlugin({
455469
profile: argv.profile
456470
}).apply(compiler);
@@ -482,6 +496,17 @@ For more information, see https://webpack.js.org/api/cli/.`);
482496
);
483497
} else if (stats.hash !== lastHash) {
484498
lastHash = stats.hash;
499+
if (stats.compilation && stats.compilation.errors.length !== 0) {
500+
const errors = stats.compilation.errors;
501+
if (errors[0].name === "EntryModuleNotFoundError") {
502+
console.error(
503+
"\n\u001b[1m\u001b[31mInsufficient number of arguments or no entry found."
504+
);
505+
console.error(
506+
"\u001b[1m\u001b[31mAlternatively, run 'webpack(-cli) --help' for usage info.\u001b[39m\u001b[22m\n"
507+
);
508+
}
509+
}
485510
const statsString = stats.toString(outputOptions);
486511
const delimiter = outputOptions.buildDelimiter
487512
? `${outputOptions.buildDelimiter}\n`

bin/config-yargs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const optionsSchema = require("webpack/schemas/WebpackOptions.json");
1+
const optionsSchema = require("./optionsSchema.json");
22
const CONFIG_GROUP = "Config options:";
33
const BASIC_GROUP = "Basic options:";
44
const MODULE_GROUP = "Module options:";

bin/convert-argv.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ const fs = require("fs");
33
fs.existsSync = fs.existsSync || path.existsSync;
44
const interpret = require("interpret");
55
const prepareOptions = require("./prepareOptions");
6-
const webpackConfigurationSchema = require("../schemas/webpackConfigurationSchema.json");
7-
const validateSchema = require("webpack").validateSchema;
8-
const WebpackOptionsValidationError = require("webpack")
9-
.WebpackOptionsValidationError;
6+
const webpackConfigurationSchema = require("./webpackConfigurationSchema.json");
7+
const validateSchema = process.webpackModule.validateSchema;
8+
const WebpackOptionsValidationError =
9+
process.webpackModule.WebpackOptionsValidationError;
1010

1111
module.exports = function(...args) {
1212
const argv = args[1] || args[0];
@@ -398,7 +398,7 @@ module.exports = function(...args) {
398398
defineObject = {};
399399
},
400400
function() {
401-
const DefinePlugin = require("webpack").DefinePlugin;
401+
const DefinePlugin = process.webpackModule.DefinePlugin;
402402
addPlugin(options, new DefinePlugin(defineObject));
403403
}
404404
);
@@ -468,13 +468,13 @@ module.exports = function(...args) {
468468
mapArgToBoolean("cache");
469469

470470
ifBooleanArg("hot", function() {
471-
const HotModuleReplacementPlugin = require("webpack")
472-
.HotModuleReplacementPlugin;
471+
const HotModuleReplacementPlugin =
472+
process.webpackModule.HotModuleReplacementPlugin;
473473
addPlugin(options, new HotModuleReplacementPlugin());
474474
});
475475

476476
ifBooleanArg("debug", function() {
477-
const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin;
477+
const LoaderOptionsPlugin = process.webpackModule.LoaderOptionsPlugin;
478478
addPlugin(
479479
options,
480480
new LoaderOptionsPlugin({
@@ -510,8 +510,8 @@ module.exports = function(...args) {
510510
});
511511

512512
ifArg("optimize-max-chunks", function(value) {
513-
const LimitChunkCountPlugin = require("webpack").optimize
514-
.LimitChunkCountPlugin;
513+
const LimitChunkCountPlugin =
514+
process.webpackModule.optimize.LimitChunkCountPlugin;
515515
addPlugin(
516516
options,
517517
new LimitChunkCountPlugin({
@@ -521,7 +521,8 @@ module.exports = function(...args) {
521521
});
522522

523523
ifArg("optimize-min-chunk-size", function(value) {
524-
const MinChunkSizePlugin = require("webpack").optimize.MinChunkSizePlugin;
524+
const MinChunkSizePlugin =
525+
process.webpackModule.optimize.MinChunkSizePlugin;
525526
addPlugin(
526527
options,
527528
new MinChunkSizePlugin({
@@ -531,7 +532,7 @@ module.exports = function(...args) {
531532
});
532533

533534
ifBooleanArg("optimize-minimize", function() {
534-
const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin;
535+
const LoaderOptionsPlugin = process.webpackModule.LoaderOptionsPlugin;
535536
addPlugin(
536537
options,
537538
new LoaderOptionsPlugin({
@@ -541,7 +542,7 @@ module.exports = function(...args) {
541542
});
542543

543544
ifArg("prefetch", function(request) {
544-
const PrefetchPlugin = require("webpack").PrefetchPlugin;
545+
const PrefetchPlugin = process.webpackModule.PrefetchPlugin;
545546
addPlugin(options, new PrefetchPlugin(request));
546547
});
547548

@@ -554,7 +555,7 @@ module.exports = function(...args) {
554555
} else {
555556
name = value;
556557
}
557-
const ProvidePlugin = require("webpack").ProvidePlugin;
558+
const ProvidePlugin = process.webpackModule.ProvidePlugin;
558559
addPlugin(options, new ProvidePlugin(name, value));
559560
});
560561

0 commit comments

Comments
 (0)