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

Commit

Permalink
chore: minimize
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Nov 13, 2020
1 parent 4d93b4f commit 07582e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/remax-cli/src/build/webpack/config.mini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function webpackConfig(builder: Builder): webpack.Configuration {
},
},
});
config.optimization.minimize(false);
config.optimization.minimize(builder.options.minimize ?? false);

if (builder.options.turboRenders) {
const options = {
Expand Down
11 changes: 8 additions & 3 deletions packages/remax-cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import yargs from 'yargs';
import { Options, Platform, Plugin } from '@remax/types';
import { Options, Plugin } from '@remax/types';
import { buildApp, buildMiniPlugin } from './build';
import getConfig from './getConfig';
import API from './API';
Expand All @@ -15,6 +15,7 @@ export default class RemaxCLI {
process.env.REMAX_PLATFORM = argv.t || argv.target || 'ali';

this.options = getConfig();
this.options.compressTemplate = this.options.compressTemplate ?? argv.minimize;
this.api = new API();
const cli = this.initCLI();
this.registerBuiltinPlugins();
Expand Down Expand Up @@ -68,6 +69,12 @@ export default class RemaxCLI {
alias: 'p',
type: 'number',
})
.option('minimize', {
describe: '最小化文件',
alias: 'm',
type: 'boolean',
default: false,
})
.option('analyze', {
describe: '编译分析',
alias: 'a',
Expand All @@ -80,7 +87,6 @@ export default class RemaxCLI {
buildApp({ ...this.options, ...argv }, this.api!);
try {
require('remax-stats').run({ type: 'remax' });
require('@alipay/remax-stats').run({ buildType: argv.target === Platform.web ? 'web-app' : 'mini-app' });
} catch (e) {
// ignore
}
Expand All @@ -107,7 +113,6 @@ export default class RemaxCLI {
buildMiniPlugin({ ...this.options, ...argv });
try {
require('remax-stats').run({ type: 'remax' });
require('@alipay/remax-stats').run({ buildType: 'mini-plugin' });
} catch (e) {
// ignore
}
Expand Down
1 change: 1 addition & 0 deletions packages/remax-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface BuildOptions {
type?: BuildType;
component?: any;
web?: WebOptions;
minimize?: boolean;
}

export type Options = BuildOptions & PluginOptions;
Expand Down

0 comments on commit 07582e7

Please sign in to comment.