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
3 changes: 2 additions & 1 deletion lib/config/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ class Validator {
if (this.webpackConfig.entries.size === 0
&& this.webpackConfig.styleEntries.size === 0
&& this.webpackConfig.copyFilesConfigs.length === 0
&& this.webpackConfig.plugins.length === 0
) {
throw new Error('No entries found! You must call addEntry() or addEntries() or addStyleEntry() or copyFiles() at least once - otherwise... there is nothing to webpack!');
throw new Error('No entries found! You must call addEntry() or addEntries() or addStyleEntry() or copyFiles() or addPlugin() 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 @@ -24,6 +24,8 @@ function createConfig() {
}

describe('The validator function', () => {
function CustomPlugin1() {}

it('throws an error if there are no entries', () => {
const config = createConfig();
config.publicPath = '/';
Expand All @@ -47,6 +49,17 @@ describe('The validator function', () => {
expect(Object.keys(config.copyFilesConfigs).length).to.equal(1);
});

it('should accept use with addPlugin() only', () => {
const config = createConfig();
config.setOutputPath('/tmp');
config.setPublicPath('/tmp');
config.addPlugin(new CustomPlugin1());

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

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