Skip to content

Commit

Permalink
feat: dev mode not use cdn config
Browse files Browse the repository at this point in the history
  • Loading branch information
hubcarl committed Aug 31, 2018
1 parent ce50e67 commit 70bcae1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ class Config {
}

getPublicPathFromCDN(url, dynamicDir) {
if (this.utils.has(url)) {
if (!this.dev && this.utils.has(url)) {
let cdnUrl = url;
let cdnDir = dynamicDir;
if (this.utils.isObject(url)) {
Expand Down
12 changes: 11 additions & 1 deletion test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,22 @@ describe('client.test.js', () => {
it('should dev cdn config test', () => {
const builder = createBuilder({ debug: true, env: 'dev', cdn: { url: cdnUrl} });
const webpackConfig = builder.create();
expect(webpackConfig.output.publicPath).to.equal('/public/');
});
it('should test cdn config test', () => {
const builder = createBuilder({ debug: true, env: 'test', cdn: { url: cdnUrl} });
const webpackConfig = builder.create();
expect(webpackConfig.output.publicPath).to.equal(cdnUrl + '/');
});
it('should prod cdn config test', () => {
const builder = createBuilder({ debug: true, env: 'prod', cdn: { url: cdnUrl} });
const webpackConfig = builder.create();
expect(webpackConfig.output.publicPath).to.equal(cdnUrl + '/');
});
it('should dev cdn dynamicDir config test', () => {
const builder = createBuilder({ debug: true, env: 'dev', cdn: { url: cdnUrl, dynamicDir: 'cdn'} });
const webpackConfig = builder.create();
expect(webpackConfig.output.publicPath).to.equal(cdnUrl + '/cdn/public/');
expect(webpackConfig.output.publicPath).to.equal('/public/');
});

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

0 comments on commit 70bcae1

Please sign in to comment.