Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: accept use with addPlugin only #1247

Merged
merged 1 commit into from
Jan 22, 2024
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.
Jump to
Jump to file
Failed to load files.
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