Skip to content

Commit 8727b42

Browse files
authored
Merge pull request #196 from andyexeter/master
Replace error throwing with logger warning when publicPath is not absolute
2 parents 00e4051 + 3270694 commit 8727b42

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

lib/WebpackConfig.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ class WebpackConfig {
125125
setPublicPath(publicPath) {
126126
if (publicPath.includes('://') === false && publicPath.indexOf('/') !== 0) {
127127
// technically, not starting with "/" is legal, but not
128-
// what you want in most cases. Let's not let the user make
129-
// a mistake (and we can always change this later).
130-
throw new Error('The value passed to setPublicPath() must start with "/" or be a full URL (http://...)');
128+
// what you want in most cases. Let's warn the user that
129+
// they might be making a mistake.
130+
logger.warning('The value passed to setPublicPath() should *usually* start with "/" or be a full URL (http://...). If you\'re not sure, then you should probably change your public path and make this message disappear.');
131131
}
132132

133133
// guarantee a single trailing slash

test/WebpackConfig.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,11 @@ describe('WebpackConfig object', () => {
9898
expect(config.publicPath).to.equal('https://example.com/');
9999
});
100100

101-
it('foo/ throws an exception', () => {
101+
it('You can omit the opening slash, but get a warning', () => {
102102
const config = createConfig();
103+
config.setPublicPath('foo');
103104

104-
expect(() => {
105-
config.setPublicPath('foo/');
106-
}).to.throw('The value passed to setPublicPath() must start with "/"');
105+
expect(logger.getMessages().warning).to.have.lengthOf(1);
107106
});
108107
});
109108

0 commit comments

Comments
 (0)