Skip to content

Commit 70bcae1

Browse files
committed
feat: dev mode not use cdn config
1 parent ce50e67 commit 70bcae1

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ class Config {
523523
}
524524

525525
getPublicPathFromCDN(url, dynamicDir) {
526-
if (this.utils.has(url)) {
526+
if (!this.dev && this.utils.has(url)) {
527527
let cdnUrl = url;
528528
let cdnDir = dynamicDir;
529529
if (this.utils.isObject(url)) {

test/client.test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,22 @@ describe('client.test.js', () => {
132132
it('should dev cdn config test', () => {
133133
const builder = createBuilder({ debug: true, env: 'dev', cdn: { url: cdnUrl} });
134134
const webpackConfig = builder.create();
135+
expect(webpackConfig.output.publicPath).to.equal('/public/');
136+
});
137+
it('should test cdn config test', () => {
138+
const builder = createBuilder({ debug: true, env: 'test', cdn: { url: cdnUrl} });
139+
const webpackConfig = builder.create();
140+
expect(webpackConfig.output.publicPath).to.equal(cdnUrl + '/');
141+
});
142+
it('should prod cdn config test', () => {
143+
const builder = createBuilder({ debug: true, env: 'prod', cdn: { url: cdnUrl} });
144+
const webpackConfig = builder.create();
135145
expect(webpackConfig.output.publicPath).to.equal(cdnUrl + '/');
136146
});
137147
it('should dev cdn dynamicDir config test', () => {
138148
const builder = createBuilder({ debug: true, env: 'dev', cdn: { url: cdnUrl, dynamicDir: 'cdn'} });
139149
const webpackConfig = builder.create();
140-
expect(webpackConfig.output.publicPath).to.equal(cdnUrl + '/cdn/public/');
150+
expect(webpackConfig.output.publicPath).to.equal('/public/');
141151
});
142152

143153
it('should dev publicPath abspath config test', () => {

0 commit comments

Comments
 (0)