-
-
Notifications
You must be signed in to change notification settings - Fork 626
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(packages/**): 架构调整,实现varlet-cli dev build命令
affects: @varlet/cli, @varlet/eslint-config, @varlet/stylelint-config, @varlet/ui 实现varlet-cli dev打包配置并启动开发服务器 实现varlet-cli build打包组件库站点生产环境代码 eslint,stylelint-config规则调整 创建子包varlet-ui
- Loading branch information
Showing
30 changed files
with
4,604 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ node_modules | |
*.log | ||
|
||
packages/varlet-cli/lib | ||
packages/varlet-ui/site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
<router-view/> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { createApp } from 'vue' | ||
import { createRouter, createWebHashHistory } from 'vue-router' | ||
import App from './App.vue' | ||
import routes from './routes' | ||
|
||
const router = createRouter({ | ||
history: createWebHashHistory(), | ||
routes | ||
}) | ||
|
||
const app = createApp(App as any) | ||
app | ||
.use(router) | ||
.mount('#app') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title><%= htmlWebpackPlugin.options.title %></title> | ||
<meta content="<%= htmlWebpackPlugin.options.description %>" name="description" /> | ||
<link href="<%= htmlWebpackPlugin.options.logo %>" rel="icon" type="image/png" /> | ||
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" name="viewport" /> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export default [ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<template> | ||
<div class="varlet-button"> | ||
<div class="varlet-button__text"> | ||
<div class="varlet-button__span--active">{{ count }}</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { ref, Ref, defineComponent } from 'vue' | ||
export default defineComponent({ | ||
setup() { | ||
const count: Ref<number> = ref(0) | ||
return { | ||
count | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<style lang="less"> | ||
.varlet { | ||
&-button { | ||
&__text { | ||
} | ||
&__span { | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title><%= htmlWebpackPlugin.options.title %></title> | ||
<meta content="<%= htmlWebpackPlugin.options.description %>" name="description" /> | ||
<link href="<%= htmlWebpackPlugin.options.logo %>" rel="icon" type="image/png" /> | ||
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" name="viewport" /> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
|
||
const app = createApp(App as any) | ||
app.mount('#app') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import webpack from 'webpack' | ||
import logger from '../shared/logger' | ||
import { buildMobileSiteRoutes } from '../shared/fsUtils' | ||
import { getBuildConfig } from '../config/webpack.build.config' | ||
import { setProd } from '../shared/env' | ||
|
||
export async function build() { | ||
try { | ||
setProd() | ||
await buildMobileSiteRoutes() | ||
const config = getBuildConfig() | ||
|
||
webpack(config, (err, stats) => { | ||
err && logger.error(err.toString()) | ||
stats.hasErrors() && logger.error(stats) | ||
}) | ||
} catch (e) { | ||
logger.error(e) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import webpack from 'webpack' | ||
import WebpackDevServer from 'webpack-dev-server' | ||
import logger from '../shared/logger' | ||
import { getDevConfig } from '../config/webpack.dev.config' | ||
import { getPort } from 'portfinder' | ||
import { buildMobileSiteRoutes } from '../shared/fsUtils' | ||
import { setDev } from '../shared/env' | ||
|
||
export function runDevServer(port: number, config: any) { | ||
const { host } = config.devServer | ||
const server = new WebpackDevServer(webpack(config), config.devServer) | ||
|
||
;(server as any).showStatus = function() {} | ||
|
||
server.listen(port, host,(err?: Error) => { | ||
if (err) { | ||
logger.error(err.toString()) | ||
return | ||
} | ||
|
||
logger.success(`Server running at http://${host}:${port}`) | ||
}) | ||
} | ||
|
||
export async function dev() { | ||
setDev() | ||
await buildMobileSiteRoutes() | ||
|
||
const config = getDevConfig() | ||
const { port } = config.devServer | ||
getPort({ | ||
port | ||
}, (err: Error, port: number) => { | ||
if (err) { | ||
logger.error(err.toString()) | ||
return | ||
} | ||
runDevServer(port, config) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { pathExistsSync } from 'fs-extra' | ||
|
||
export function createPostcssOptions(path: string) { | ||
const defaultConfig = { | ||
postcssOptions: { | ||
plugins: ['autoprefixer'] | ||
} | ||
} | ||
|
||
return pathExistsSync(path) | ||
? { | ||
postcssOptions: { | ||
config: path, | ||
plugins: ['autoprefixer'] | ||
} | ||
} | ||
: defaultConfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { pathExistsSync } from 'fs-extra' | ||
import { VARLET_CONFIG } from '../shared/constant' | ||
|
||
export const defaultConfig = { | ||
pc: { | ||
title: 'Varlet 组件库文档', | ||
description: 'Varlet 组件库文档', | ||
logo: 'https://cn.vuejs.org/images/logo.png' | ||
}, | ||
mobile: { | ||
title: 'Varlet 组件库示例', | ||
description: 'Varlet 组件库示例', | ||
logo: 'https://cn.vuejs.org/images/logo.png' | ||
} | ||
} | ||
|
||
export function getVarletConfig() { | ||
return pathExistsSync(VARLET_CONFIG) && require(VARLET_CONFIG) || defaultConfig | ||
} |
Oops, something went wrong.