Skip to content

Commit 7c6f390

Browse files
authored
feat: added --no-devtool to webpack v4(#2603)
1 parent f92a846 commit 7c6f390

File tree

7 files changed

+42
-5
lines changed

7 files changed

+42
-5
lines changed

packages/webpack-cli/lib/webpack-cli.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,10 @@ class WebpackCLI {
515515
{
516516
type: 'string',
517517
},
518+
{
519+
type: 'enum',
520+
values: [false],
521+
},
518522
],
519523
negative: true,
520524
alias: 'd',

test/build/devtool/array/source-map-array.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ describe('source-map object', () => {
99

1010
expect(exitCode).toBe(0);
1111
expect(stderr).toBeFalsy();
12-
expect(stdout).toBeTruthy();
12+
// multi compilers
13+
expect(stdout).toContain("devtool: 'source-map'");
14+
expect(stdout).toContain("devtool: 'eval-cheap-module-source-map'");
1315

1416
let files;
1517

@@ -27,7 +29,7 @@ describe('source-map object', () => {
2729

2830
expect(exitCode).toBe(0);
2931
expect(stderr).toBeFalsy();
30-
expect(stdout).toBeTruthy();
32+
expect(stdout).toContain("devtool: 'source-map'");
3133

3234
let files;
3335

test/build/devtool/array/webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const WebpackCLITestPlugin = require('../../../utils/webpack-cli-test-plugin');
2+
13
module.exports = [
24
{
35
output: {
@@ -8,6 +10,7 @@ module.exports = [
810
entry: './index.js',
911
mode: 'development',
1012
devtool: 'eval-cheap-module-source-map',
13+
plugins: [new WebpackCLITestPlugin()],
1114
},
1215
{
1316
output: {
@@ -19,5 +22,6 @@ module.exports = [
1922
mode: 'development',
2023
devtool: 'source-map',
2124
target: 'node',
25+
plugins: [new WebpackCLITestPlugin()],
2226
},
2327
];

test/build/devtool/object/source-map-object.test.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('source-map object', () => {
99

1010
expect(exitCode).toBe(0);
1111
expect(stderr).toBeFalsy();
12-
expect(stdout).toBeTruthy();
12+
expect(stdout).toContain("devtool: 'eval-cheap-module-source-map'");
1313

1414
let files;
1515

@@ -27,7 +27,7 @@ describe('source-map object', () => {
2727

2828
expect(exitCode).toBe(0);
2929
expect(stderr).toBeFalsy();
30-
expect(stdout).toBeTruthy();
30+
expect(stdout).toContain("devtool: 'source-map'");
3131
expect(existsSync(resolve(__dirname, 'dist/dist-amd.js.map'))).toBeTruthy();
3232
});
3333

@@ -40,7 +40,20 @@ describe('source-map object', () => {
4040

4141
expect(exitCode).toBe(0);
4242
expect(stderr).toBeFalsy();
43-
expect(stdout).toBeTruthy();
43+
expect(stdout).toContain("devtool: 'source-map'");
44+
expect(existsSync(resolve(__dirname, 'binary/dist-amd.js.map'))).toBeTruthy();
45+
});
46+
47+
it('should override config with devtool false', async () => {
48+
const { exitCode, stderr, stdout } = await run(
49+
__dirname,
50+
['-c', './webpack.eval.config.js', '--no-devtool', '-o', './binary'],
51+
false,
52+
);
53+
54+
expect(exitCode).toBe(0);
55+
expect(stderr).toBeFalsy();
56+
expect(stdout).toContain('devtool: false');
4457
expect(existsSync(resolve(__dirname, 'binary/dist-amd.js.map'))).toBeTruthy();
4558
});
4659
});

test/build/devtool/object/webpack.eval.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const WebpackCLITestPlugin = require('../../../utils/webpack-cli-test-plugin');
2+
13
module.exports = {
24
output: {
35
filename: './dist-amd.js',
@@ -7,4 +9,5 @@ module.exports = {
79
entry: './index.js',
810
mode: 'development',
911
devtool: 'eval-cheap-module-source-map',
12+
plugins: [new WebpackCLITestPlugin()],
1013
};

test/build/devtool/object/webpack.source.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const WebpackCLITestPlugin = require('../../../utils/webpack-cli-test-plugin');
2+
13
module.exports = {
24
output: {
35
filename: './dist-amd.js',
@@ -7,4 +9,5 @@ module.exports = {
79
entry: './index.js',
810
mode: 'development',
911
devtool: 'source-map',
12+
plugins: [new WebpackCLITestPlugin()],
1013
};

test/help/__snapshots__/help.test.js.snap.webpack4

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Options:
7777
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
7878
-t, --target <value> Sets the build target e.g. node.
7979
-d, --devtool <value> Determine source maps to use.
80+
--no-devtool Do not generate source maps.
8081
--mode <value> Defines the mode to pass to webpack.
8182
--name <value> Name of the configuration. Used when loading multiple configurations.
8283
--stats [value] It instructs webpack on how to treat the stats e.g. verbose.
@@ -130,6 +131,7 @@ Options:
130131
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
131132
-t, --target <value> Sets the build target e.g. node.
132133
-d, --devtool <value> Determine source maps to use.
134+
--no-devtool Do not generate source maps.
133135
--mode <value> Defines the mode to pass to webpack.
134136
--name <value> Name of the configuration. Used when loading multiple configurations.
135137
--stats [value] It instructs webpack on how to treat the stats e.g. verbose.
@@ -183,6 +185,7 @@ Options:
183185
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
184186
-t, --target <value> Sets the build target e.g. node.
185187
-d, --devtool <value> Determine source maps to use.
188+
--no-devtool Do not generate source maps.
186189
--mode <value> Defines the mode to pass to webpack.
187190
--name <value> Name of the configuration. Used when loading multiple configurations.
188191
--stats [value] It instructs webpack on how to treat the stats e.g. verbose.
@@ -240,6 +243,7 @@ Options:
240243
e.g. ./dist/.
241244
-t, --target <value> Sets the build target e.g. node.
242245
-d, --devtool <value> Determine source maps to use.
246+
--no-devtool Do not generate source maps.
243247
--mode <value> Defines the mode to pass to webpack.
244248
--name <value> Name of the configuration. Used when loading
245249
multiple configurations.
@@ -418,6 +422,7 @@ Options:
418422
e.g. ./dist/.
419423
-t, --target <value> Sets the build target e.g. node.
420424
-d, --devtool <value> Determine source maps to use.
425+
--no-devtool Do not generate source maps.
421426
--mode <value> Defines the mode to pass to webpack.
422427
--name <value> Name of the configuration. Used when loading
423428
multiple configurations.
@@ -500,6 +505,7 @@ Options:
500505
e.g. ./dist/.
501506
-t, --target <value> Sets the build target e.g. node.
502507
-d, --devtool <value> Determine source maps to use.
508+
--no-devtool Do not generate source maps.
503509
--mode <value> Defines the mode to pass to webpack.
504510
--name <value> Name of the configuration. Used when loading
505511
multiple configurations.
@@ -542,6 +548,7 @@ Options:
542548
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
543549
-t, --target <value> Sets the build target e.g. node.
544550
-d, --devtool <value> Determine source maps to use.
551+
--no-devtool Do not generate source maps.
545552
--mode <value> Defines the mode to pass to webpack.
546553
--name <value> Name of the configuration. Used when loading multiple configurations.
547554
--stats [value] It instructs webpack on how to treat the stats e.g. verbose.
@@ -595,6 +602,7 @@ Options:
595602
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
596603
-t, --target <value> Sets the build target e.g. node.
597604
-d, --devtool <value> Determine source maps to use.
605+
--no-devtool Do not generate source maps.
598606
--mode <value> Defines the mode to pass to webpack.
599607
--name <value> Name of the configuration. Used when loading multiple configurations.
600608
--stats [value] It instructs webpack on how to treat the stats e.g. verbose.

0 commit comments

Comments
 (0)