Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class ConfigGenerator {
// this still doesn't remove all output
let stats = {};

if (!this.webpackConfig.runtimeConfig.outputJson) {
if (!this.webpackConfig.runtimeConfig.outputJson && !this.webpackConfig.runtimeConfig.profile) {
stats = {
hash: false,
version: false,
Expand Down
5 changes: 5 additions & 0 deletions lib/config/parse-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = function(argv, cwd) {
runtimeConfig.useDevServer = false;
runtimeConfig.useHotModuleReplacement = false;
runtimeConfig.outputJson = false;
runtimeConfig.profile = false;

switch (runtimeConfig.command) {
case 'dev':
Expand Down Expand Up @@ -73,6 +74,10 @@ module.exports = function(argv, cwd) {
runtimeConfig.outputJson = true;
}

if (argv.profile) {
runtimeConfig.profile = true;
}

runtimeConfig.babelRcFileExists = (typeof resolveRc(require('fs'), runtimeConfig.context)) !== 'undefined';

return runtimeConfig;
Expand Down
32 changes: 32 additions & 0 deletions test/bin/encore.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,36 @@ module.exports = Encore.getWebpackConfig();
done();
});
});

it('Smoke test using the --profile option', (done) => {
testSetup.emptyTmpDir();
const testDir = testSetup.createTestAppDir();

fs.writeFileSync(
path.join(testDir, 'webpack.config.js'),
`
const Encore = require('../../index.js');
Encore
.setOutputPath('build/')
.setPublicPath('/build')
.addEntry('main', './js/no_require')
;

module.exports = Encore.getWebpackConfig();
`
);

const binPath = path.resolve(__dirname, '../', '../', 'bin', 'encore.js');
exec(`node ${binPath} dev --profile --context=${testDir}`, { cwd: testDir }, (err, stdout, stderr) => {
if (err) {
throw new Error(`Error executing encore: ${err} ${stderr} ${stdout}`);
}

expect(stdout).to.contain('Hash: ');
expect(stdout).to.contain('Version: ');
expect(stdout).to.contain('Time: ');

done();
});
});
});