-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): fix file resolution inside group helper (#1221)
* fix(cli): fix file resolution inside group helper * fix(cli): default output bundle is main.js
- Loading branch information
Showing
11 changed files
with
100 additions
and
14 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,26 @@ | ||
const ZeroConfigGroup = require('../lib/groups/ZeroConfigGroup'); | ||
|
||
describe('GroupHelper', function() { | ||
it('should load the dev zero config', () => { | ||
const group = new ZeroConfigGroup([ | ||
{ | ||
dev: true, | ||
}, | ||
]); | ||
|
||
const result = group.run(); | ||
expect(result.options.mode).toEqual('development'); | ||
}); | ||
it('should load the prod zero config', () => { | ||
const group = new ZeroConfigGroup([ | ||
[ | ||
{ | ||
prod: true, | ||
}, | ||
], | ||
]); | ||
|
||
const result = group.run(); | ||
expect(result.options.mode).toEqual('production'); | ||
}); | ||
}); |
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('environment is '.concat(PRODUCTION ? 'production' : 'development')); |
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,27 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const execa = require('execa'); | ||
const { sync: spawnSync } = execa; | ||
|
||
const { run } = require('../../utils/test-utils'); | ||
|
||
describe('env object', () => { | ||
it('is able to compile successfully with --prod flag', () => { | ||
const { stderr, stdout } = run(__dirname, ['--prod']); | ||
const executable = path.join(__dirname, './bin/main.js'); | ||
const bundledScript = spawnSync('node', [executable]); | ||
expect(bundledScript.stdout).toBe('environment is production'); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
}); | ||
|
||
it('is able to compile successfully with -p flag', () => { | ||
const { stderr, stdout } = run(__dirname, ['-p']); | ||
const executable = path.join(__dirname, './bin/main.js'); | ||
const bundledScript = spawnSync('node', [executable]); | ||
expect(bundledScript.stdout).toBe('environment is production'); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
}); | ||
}); |
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,11 @@ | ||
const webpack = require('webpack'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
devtool: 'eval-cheap-module-source-map', | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
PRODUCTION: JSON.stringify(true), | ||
}), | ||
], | ||
}; |
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