Skip to content

Commit

Permalink
feature #831 Validator should allow copyFiles() without other entries…
Browse files Browse the repository at this point in the history
…. (pszalko)

This PR was squashed before being merged into the main branch.

Discussion
----------

Validator should allow copyFiles() without other entries.

Fix for #830

Commits
-------

f6d3cb7 Validator should allow copyFiles() without other entries.
  • Loading branch information
weaverryan committed Dec 3, 2020
2 parents 39b761a + f6d3cb7 commit a11348c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/config/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ class Validator {
throw new Error('Missing public path: Call setPublicPath() to control the public path relative to where the files are written (the output path).');
}

if (this.webpackConfig.entries.size === 0 && this.webpackConfig.styleEntries.size === 0) {
throw new Error('No entries found! You must call addEntry() or addStyleEntry() at least once - otherwise... there is nothing to webpack!');
if (this.webpackConfig.entries.size === 0
&& this.webpackConfig.styleEntries.size === 0
&& this.webpackConfig.copyFilesConfigs.length === 0
) {
throw new Error('No entries found! You must call addEntry() or addStyleEntry() or copyFiles() at least once - otherwise... there is nothing to webpack!');
}
}

Expand Down
13 changes: 13 additions & 0 deletions test/config/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ describe('The validator function', () => {
}).to.throw('No entries found!');
});

it('should accept use with copyFiles() only', () => {
const config = createConfig();
config.setOutputPath('/tmp');
config.setPublicPath('/tmp');
config.copyFiles({ from: './' });

expect(() => {
validator(config);
}).not.throw();

expect(Object.keys(config.copyFilesConfigs).length).to.equal(1);
});

it('throws an error if there is no output path', () => {
const config = createConfig();
config.publicPath = '/';
Expand Down

0 comments on commit a11348c

Please sign in to comment.