Skip to content

Commit

Permalink
fix(cli): 启动生成varlet.config.js
Browse files Browse the repository at this point in the history
affects: @varlet/cli
  • Loading branch information
haoziqaq committed Nov 23, 2020
1 parent 31f885b commit d8dfa5e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/varlet-cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import logger from '../shared/logger'
import { buildMobileSiteRoutes, buildPcSiteRoutes } from '../compiler/compileRoutes'
import { getBuildConfig } from '../config/webpack.build.config'
import { setProd } from '../shared/env'
import { pathExistsSync, writeFileSync } from 'fs-extra'
import { VARLET_CONFIG } from '../shared/constant'

export async function build() {
setProd()

!pathExistsSync(VARLET_CONFIG) && writeFileSync(VARLET_CONFIG, 'module.exports = {}')

await Promise.all([
buildMobileSiteRoutes(),
buildPcSiteRoutes()
Expand Down
4 changes: 4 additions & 0 deletions packages/varlet-cli/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { getDevConfig } from '../config/webpack.dev.config'
import { getPort } from 'portfinder'
import { buildMobileSiteRoutes, buildPcSiteRoutes } from '../compiler/compileRoutes'
import { setDev } from '../shared/env'
import { pathExistsSync, writeFileSync } from 'fs-extra'
import { VARLET_CONFIG } from '../shared/constant'

export function runDevServer(port: number, config: any) {
const { host } = config.devServer
Expand All @@ -25,6 +27,8 @@ export function runDevServer(port: number, config: any) {
export async function dev() {
setDev()

!pathExistsSync(VARLET_CONFIG) && writeFileSync(VARLET_CONFIG, 'module.exports = {}')

await Promise.all([
buildMobileSiteRoutes(),
buildPcSiteRoutes()
Expand Down
3 changes: 1 addition & 2 deletions packages/varlet-cli/src/config/webpack.base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import HtmlWebpackPlugin from 'html-webpack-plugin'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import { resolve } from 'path'
import {
CWD,
EXTENSIONS,
POSTCSS_CONFIG,
TS_CONFIG,
Expand All @@ -11,7 +10,7 @@ import {
import { createPostcssOptions } from './postcss.config'
import { ForkTsCheckerWebpackPlugin } from 'fork-ts-checker-webpack-plugin/lib/ForkTsCheckerWebpackPlugin'
import { VueLoaderPlugin } from 'vue-loader'
import { pathExistsSync } from 'fs-extra'
import { pathExistsSync, writeFileSync } from 'fs-extra'
import { WebpackPluginInstance } from 'webpack'
import { isDev } from '../shared/env'
import { accessProperty } from '../shared/fsUtils'
Expand Down

0 comments on commit d8dfa5e

Please sign in to comment.