Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
feat(cli): 新增 -a 参数用于分析构建后的包依赖 (#1014)
Browse files Browse the repository at this point in the history
* feat(cli):  支持 analyzer

resolved #958

* test: update snapshot

* fix: 使用 puppeteer 3.1 版本

* chore: options analyze

* test: update snapshot

* test: webpack config work

* test: 测试 webpack analye 参数
  • Loading branch information
noyobo authored Jun 5, 2020
1 parent 93bbd2c commit 97759d1
Show file tree
Hide file tree
Showing 73 changed files with 1,192 additions and 1,098 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@types/webpack-dev-middleware": "^3.7.0",
"concurrently": "^5.2.0",
"lint-staged": ">=8",
"puppeteer": "^3.1.0",
"puppeteer": "~3.1.0",
"rimraf": "^3.0.2"
},
"collective": {
Expand Down
1 change: 1 addition & 0 deletions packages/remax-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"style-loader": "^1.1.3",
"universal-analytics": "^0.4.20",
"webpack": "^4.42.1",
"webpack-bundle-analyzer": "^3.8.0",
"webpack-chain": "^6.4.0",
"webpack-dev-server": "^3.10.3",
"webpack-sources": "^1.4.3",
Expand Down
34 changes: 34 additions & 0 deletions packages/remax-cli/src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import * as path from 'path';
import readManifest from '../readManifest';
import { Platform } from '@remax/types';

import configWeb from '../build/webpack/config.web';
import configMini from '../build/webpack/config.mini';
import API from '../API';
import { getDefaultOptions } from '../defaultOptions';

describe('manifest', () => {
it('throw error when file not exists with strict mode enabled', () => {
expect(readManifest('', Platform.ali)).toEqual({});
Expand All @@ -22,3 +27,32 @@ describe('manifest', () => {
).toMatchObject({});
});
});

describe('web webpack config', () => {
it('is work', async () => {
const options = getDefaultOptions();
options.cwd = path.join(__dirname, './integration/fixtures/wechat');
options.analyze = true;
options.configWebpack = ({ config }) => {
expect(config.entryPoints.has('index')).toBe(true);
expect(config.plugins.has('webpack-bundle-analyzer')).toBe(true);
};

configWeb(new API(), options);
});
});

describe('mini webpack config', () => {
it('is work', async () => {
const options = getDefaultOptions();
const projectRoot = path.join(__dirname, './integration/fixtures/wechat');
options.cwd = projectRoot;
options.analyze = true;
options.configWebpack = ({ config }) => {
expect(config.entryPoints.has('pages/index')).toBe(true);
expect(config.plugins.has('webpack-bundle-analyzer')).toBe(true);
};

configMini(new API(), options, Platform.wechat);
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

1 comment on commit 97759d1

@vercel
Copy link

@vercel vercel bot commented on 97759d1 Jun 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.