Skip to content

Commit

Permalink
feat: add verbose mode
Browse files Browse the repository at this point in the history
closes #9
  • Loading branch information
mastilver committed Jul 2, 2017
1 parent 1b772d1 commit fb79805
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ Default: `[]`

List the modules that will always be bundled (not be served by the cdn)

#### options.verbose

Type: `boolean`<br>
Default: `false`

Log whether the library is being served by the cdn or is bundled

## Related

Expand Down
10 changes: 9 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ try {
}

export default class ModulesCdnWebpackPlugin {
constructor({disable = false, env, exclude, only} = {}) {
constructor({disable = false, env, exclude, only, verbose} = {}) {
if (exclude && only) {
throw new Error('You can\'t use \'exclude\' and \'only\' at the same time');
}
Expand All @@ -24,6 +24,7 @@ export default class ModulesCdnWebpackPlugin {
this.urls = {};
this.exclude = exclude || [];
this.only = only || null;
this.verbose = verbose === true;
}

apply(compiler) {
Expand Down Expand Up @@ -74,9 +75,16 @@ export default class ModulesCdnWebpackPlugin {
const cdnConfig = moduleToCdn(modulePath, version, {env});

if (cdnConfig == null) {
if (this.verbose) {
console.log(`❌ '${modulePath}' couldn't be find, please add it to https:/mastilver/module-to-cdn/blob/master/modules.json`);
}
return false;
}

if (this.verbose) {
console.log(`✔️ '${cdnConfig.name}' will be served by ${cdnConfig.url}`);
}

if (peerDependencies) {
for (const peerDependencyName in peerDependencies) {
if ({}.hasOwnProperty.call(peerDependencies, peerDependencyName)) {
Expand Down

0 comments on commit fb79805

Please sign in to comment.