Skip to content

Commit 9ac995e

Browse files
committed
bug #299 Use default stats output when called with --profile (Lyrkan)
This PR was merged into the master branch. Discussion ---------- Use default stats output when called with --profile This PR closes #231 by detecting if Encore was called with the `--profile` option and using the default `stats` Webpack option in that case. Commits ------- fe97991 Use default stats output when called with --profile
2 parents f0a18b2 + fe97991 commit 9ac995e

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

lib/config-generator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class ConfigGenerator {
288288
// this still doesn't remove all output
289289
let stats = {};
290290

291-
if (!this.webpackConfig.runtimeConfig.outputJson) {
291+
if (!this.webpackConfig.runtimeConfig.outputJson && !this.webpackConfig.runtimeConfig.profile) {
292292
stats = {
293293
hash: false,
294294
version: false,

lib/config/parse-runtime.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module.exports = function(argv, cwd) {
2525
runtimeConfig.useDevServer = false;
2626
runtimeConfig.useHotModuleReplacement = false;
2727
runtimeConfig.outputJson = false;
28+
runtimeConfig.profile = false;
2829

2930
switch (runtimeConfig.command) {
3031
case 'dev':
@@ -73,6 +74,10 @@ module.exports = function(argv, cwd) {
7374
runtimeConfig.outputJson = true;
7475
}
7576

77+
if (argv.profile) {
78+
runtimeConfig.profile = true;
79+
}
80+
7681
runtimeConfig.babelRcFileExists = (typeof resolveRc(require('fs'), runtimeConfig.context)) !== 'undefined';
7782

7883
return runtimeConfig;

test/bin/encore.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,36 @@ module.exports = Encore.getWebpackConfig();
123123
done();
124124
});
125125
});
126+
127+
it('Smoke test using the --profile option', (done) => {
128+
testSetup.emptyTmpDir();
129+
const testDir = testSetup.createTestAppDir();
130+
131+
fs.writeFileSync(
132+
path.join(testDir, 'webpack.config.js'),
133+
`
134+
const Encore = require('../../index.js');
135+
Encore
136+
.setOutputPath('build/')
137+
.setPublicPath('/build')
138+
.addEntry('main', './js/no_require')
139+
;
140+
141+
module.exports = Encore.getWebpackConfig();
142+
`
143+
);
144+
145+
const binPath = path.resolve(__dirname, '../', '../', 'bin', 'encore.js');
146+
exec(`node ${binPath} dev --profile --context=${testDir}`, { cwd: testDir }, (err, stdout, stderr) => {
147+
if (err) {
148+
throw new Error(`Error executing encore: ${err} ${stderr} ${stdout}`);
149+
}
150+
151+
expect(stdout).to.contain('Hash: ');
152+
expect(stdout).to.contain('Version: ');
153+
expect(stdout).to.contain('Time: ');
154+
155+
done();
156+
});
157+
});
126158
});

0 commit comments

Comments
 (0)