diff --git a/README.md b/README.md index 9ea5ee83f6e3..a427c0ca0a71 100644 --- a/README.md +++ b/README.md @@ -171,3 +171,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +添加一行代码 \ No newline at end of file diff --git a/packages/taro-cli/bin/taro-build b/packages/taro-cli/bin/taro-build index 4e64438fa681..2dcd9490e925 100755 --- a/packages/taro-cli/bin/taro-build +++ b/packages/taro-cli/bin/taro-build @@ -18,9 +18,10 @@ program .option('--plugin [typeName]', 'Build Taro plugin project, weapp') .option('--port [port]', 'Specified port') .option('--release', 'Release quickapp') + .option('--buildVersion [buildVersionName]', 'Build version, 1.0.0/2.0.0-bate.1') .parse(process.argv) -const { type, watch, ui, port, release } = program +const { type, watch, ui, port, release, buildVersion } = program let { env, plugin } = program env = process.env.NODE_ENV || env @@ -70,5 +71,6 @@ build(appPath, { type, watch, port: typeof port === 'string' ? port: undefined, - release: !!release + release: !!release, + buildVersion: typeof buildVersion === 'string' ? buildVersion : undefined }) diff --git a/packages/taro-cli/src/build.ts b/packages/taro-cli/src/build.ts index b6b678b8ada8..9efbd49efd54 100644 --- a/packages/taro-cli/src/build.ts +++ b/packages/taro-cli/src/build.ts @@ -8,8 +8,8 @@ import CONFIG from './config' import { BUILD_TYPES, PROJECT_CONFIG } from './util/constants' import { IBuildConfig } from './util/types' -export default function build (appPath, buildConfig: IBuildConfig) { - const { type, watch, platform, port, release } = buildConfig +export default function build(appPath, buildConfig: IBuildConfig) { + const { type, watch, platform, port, release, buildVersion } = buildConfig const configDir = require(path.join(appPath, PROJECT_CONFIG))(_.merge) const outputPath = path.join(appPath, configDir.outputRoot || CONFIG.OUTPUT_DIR) if (!fs.existsSync(outputPath)) { @@ -19,7 +19,7 @@ export default function build (appPath, buildConfig: IBuildConfig) { } switch (type) { case BUILD_TYPES.H5: - buildForH5(appPath, { watch, port }) + buildForH5(appPath, { watch, port,buildVersion }) break case BUILD_TYPES.WEAPP: buildForWeapp(appPath, { watch }) diff --git a/packages/taro-cli/src/h5/index.ts b/packages/taro-cli/src/h5/index.ts index dc695135b52a..6464024420d7 100644 --- a/packages/taro-cli/src/h5/index.ts +++ b/packages/taro-cli/src/h5/index.ts @@ -173,7 +173,7 @@ class Compiler { }) } - async buildDist ({ watch, port }: IBuildConfig) { + async buildDist({ watch, port, buildVersion }: IBuildConfig) { const entryFileName = this.entryFileName const projectConfig = this.projectConfig const h5Config = this.h5Config @@ -205,6 +205,9 @@ class Compiler { port, sourceRoot }) + if (watch == undefined && buildVersion) { + h5Config.outputRoot = buildVersion; + } const webpackRunner = await npmProcess.getNpmPkg('@tarojs/webpack-runner', this.appPath) webpackRunner(this.appPath, h5Config) diff --git a/packages/taro-cli/src/util/types.ts b/packages/taro-cli/src/util/types.ts index 193dadeba9a5..f2fdd40bdcfa 100644 --- a/packages/taro-cli/src/util/types.ts +++ b/packages/taro-cli/src/util/types.ts @@ -49,7 +49,8 @@ export interface IBuildConfig { watch?: boolean, platform?: string, port?: number, - release?: boolean + release?: boolean, + buildVersion?: string } export interface IMiniAppBuildConfig {