-
-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webpack-cli): added mode argument (#1253)
- Loading branch information
Showing
13 changed files
with
193 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{ | ||
"presets": [[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": "current" | ||
} | ||
} | ||
], | ||
"jest" | ||
] | ||
} | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": "current" | ||
} | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,4 @@ junit.xml | |
|
||
#typescript source maps | ||
packages/**/*.map | ||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
const { run } = require('../../utils/test-utils'); | ||
const { stat } = require('fs'); | ||
const { resolve } = require('path'); | ||
describe('mode flags', () => { | ||
it('should load a development config when --dev is passed', done => { | ||
const { stderr, stdout } = run(__dirname, ['--dev']); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
stat(resolve(__dirname, './bin/main.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should load a development config when --mode=development is passed', done => { | ||
const { stderr, stdout } = run(__dirname, ['--mode', 'development']); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
stat(resolve(__dirname, './bin/main.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should load a development config when --mode=development and --dev are passed', done => { | ||
const { stderr, stdout } = run(__dirname, ['--mode', 'development', '--dev']); | ||
expect(stderr).toContain('"mode" will be used'); | ||
expect(stdout).toBeTruthy(); | ||
|
||
stat(resolve(__dirname, './bin/main.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should load a development config when --mode=development and --prod are passed', done => { | ||
const { stderr, stdout } = run(__dirname, ['--mode', 'development', '--prod']); | ||
expect(stderr).toContain('"mode" will be used'); | ||
expect(stdout).toBeTruthy(); | ||
|
||
stat(resolve(__dirname, './bin/main.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('default'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'use strict'; | ||
const { run } = require('../../utils/test-utils'); | ||
const { stat } = require('fs'); | ||
const { resolve } = require('path'); | ||
describe('mode flags', () => { | ||
it('should load a production config when --prod is passed', done => { | ||
const { stderr, stdout } = run(__dirname, ['--prod']); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
stat(resolve(__dirname, './bin/main.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should load a production config when --mode=production is passed', done => { | ||
const { stderr, stdout } = run(__dirname, ['--mode', 'production']); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
stat(resolve(__dirname, './bin/main.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should load a production config when --mode=production and --prod are passed', done => { | ||
const { stderr, stdout } = run(__dirname, ['--mode', 'production', '--prod']); | ||
expect(stderr).toContain('"mode" will be used'); | ||
expect(stdout).toBeTruthy(); | ||
|
||
stat(resolve(__dirname, './bin/main.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should load a production config when --mode=production and --dev are passed', done => { | ||
const { stderr, stdout } = run(__dirname, ['--mode', 'production', '--dev']); | ||
expect(stderr).toContain('"mode" will be used'); | ||
expect(stdout).toBeTruthy(); | ||
|
||
stat(resolve(__dirname, './bin/main.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should load a production config when passing --dev and --prod', done => { | ||
const { stderr, stdout } = run(__dirname, ['--prod', '--dev']); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
|
||
stat(resolve(__dirname, './bin/main.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('default'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters