diff --git a/lib/config/validator.js b/lib/config/validator.js index 6e1d0965..60c3aa73 100644 --- a/lib/config/validator.js +++ b/lib/config/validator.js @@ -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!'); } } diff --git a/test/config/validator.js b/test/config/validator.js index 61d477e5..cab05984 100644 --- a/test/config/validator.js +++ b/test/config/validator.js @@ -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 = '/'; @@ -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 = '/';