Skip to content

Commit a11348c

Browse files
committed
feature #831 Validator should allow copyFiles() without other entries. (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.
2 parents 39b761a + f6d3cb7 commit a11348c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/config/validator.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ class Validator {
4242
throw new Error('Missing public path: Call setPublicPath() to control the public path relative to where the files are written (the output path).');
4343
}
4444

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

test/config/validator.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ describe('The validator function', () => {
3434
}).to.throw('No entries found!');
3535
});
3636

37+
it('should accept use with copyFiles() only', () => {
38+
const config = createConfig();
39+
config.setOutputPath('/tmp');
40+
config.setPublicPath('/tmp');
41+
config.copyFiles({ from: './' });
42+
43+
expect(() => {
44+
validator(config);
45+
}).not.throw();
46+
47+
expect(Object.keys(config.copyFilesConfigs).length).to.equal(1);
48+
});
49+
3750
it('throws an error if there is no output path', () => {
3851
const config = createConfig();
3952
config.publicPath = '/';

0 commit comments

Comments
 (0)