Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mix.dump() and mix.dumpWebpackConfig();
This is a debug command that will dump the generated Webpack config to your console.
- Loading branch information
1 parent
e08ab24
commit d14f7dc
Showing
4 changed files
with
44 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class DumpWebpackConfig { | ||
/** | ||
* The optional name to be used when called by Mix. | ||
* Defaults to the class name, lowercased. | ||
*/ | ||
name() { | ||
return ['dumpWebpackConfig', 'dump']; | ||
} | ||
|
||
/** | ||
* Register the component. | ||
*/ | ||
register() { | ||
Mix.listen('configReady', config => { | ||
console.log(JSON.stringify(config, null, 2)); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = DumpWebpackConfig; |
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,21 @@ | ||
import mix from './helpers/setup'; | ||
|
||
test.serial.cb('mix.dumpWebpackConfig()', t => { | ||
let config; | ||
|
||
console.log = webpackConfig => { | ||
config = JSON.parse(webpackConfig); | ||
}; | ||
|
||
mix.js( | ||
'test/fixtures/fake-app/resources/assets/js/app.js', | ||
'js' | ||
).dumpWebpackConfig(); | ||
|
||
compile(t, () => { | ||
// Quick test to ensure that a webpack config object was logged. | ||
t.truthy(config.context); | ||
t.true(typeof config.module === 'object'); | ||
t.true(typeof config.plugins === 'object'); | ||
}); | ||
}); |