@farris/cli 1.0.27 → 2.0.0-beta.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/bin/index.js +2 -0
  2. package/lib/commands/build-components.js +36 -0
  3. package/lib/commands/build-css.js +11 -0
  4. package/lib/commands/build-lib.js +16 -0
  5. package/lib/commands/build.js +10 -0
  6. package/lib/commands/create-app.js +54 -0
  7. package/lib/commands/dev-serve.js +23 -0
  8. package/lib/commands/preview-serve.js +16 -0
  9. package/lib/common/constant.js +18 -0
  10. package/lib/common/generate-app.js +44 -0
  11. package/lib/common/get-dependencies.js +9 -0
  12. package/lib/common/get-farris-config.js +11 -0
  13. package/lib/common/get-version.js +6 -0
  14. package/lib/common/get-vite-config.js +38 -0
  15. package/lib/config/vite-app.js +14 -0
  16. package/lib/config/vite-lib.js +35 -0
  17. package/lib/index.js +54 -0
  18. package/lib/plugins/dts.js +8 -0
  19. package/lib/plugins/gen-component-style.js +43 -0
  20. package/lib/plugins/html-system.js +11 -0
  21. package/lib/plugins/replace.js +13 -0
  22. package/package.json +30 -18
  23. package/templates/lib/.eslintrc.cjs +15 -0
  24. package/templates/lib/.prettierrc.json +8 -0
  25. package/templates/lib/farris.config.mjs +35 -0
  26. package/templates/lib/index.html +12 -0
  27. package/templates/lib/package.json +29 -0
  28. package/templates/lib/packages/button/src/index.vue +4 -0
  29. package/templates/lib/packages/index.ts +7 -0
  30. package/templates/lib/src/App.vue +5 -0
  31. package/templates/lib/src/main.ts +9 -0
  32. package/templates/lib/tsconfig.json +18 -0
  33. package/templates/mobile/.eslintrc.cjs +15 -0
  34. package/templates/mobile/.prettierrc.json +8 -0
  35. package/templates/mobile/farris.config.mjs +24 -0
  36. package/templates/mobile/index.html +12 -0
  37. package/templates/mobile/package.json +29 -0
  38. package/templates/mobile/src/App.vue +80 -0
  39. package/templates/mobile/src/components/TheButton.vue +3 -0
  40. package/templates/mobile/src/main.ts +12 -0
  41. package/templates/mobile/src/router/index.ts +23 -0
  42. package/templates/mobile/src/views/AboutView.vue +15 -0
  43. package/templates/mobile/src/views/HomeView.vue +9 -0
  44. package/templates/mobile/tsconfig.json +18 -0
  45. package/README.md +0 -2
  46. package/ci/cli.js +0 -542
package/bin/index.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../lib/index.js';
@@ -0,0 +1,36 @@
1
+ import { readdirSync, lstatSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { buildCommon } from "./build.js";
4
+ import { CWD } from "../common/constant.js";
5
+ import { replace } from "../plugins/replace.js";
6
+ import { genComponentStyle } from "../plugins/gen-component-style.js";
7
+ export async function buildComponents(options) {
8
+ const components = readdirSync("./components").filter((name) => {
9
+ const componentDir = resolve(CWD, `./components`, name);
10
+ const isDir = lstatSync(componentDir).isDirectory();
11
+ return isDir && readdirSync(componentDir).includes("index.ts");
12
+ });
13
+ components.forEach(async (component) => {
14
+ const entry = resolve(CWD, `./components/${component}/index.ts`);
15
+ const outDir = resolve(CWD, `./package/${component}`);
16
+ const config = {
17
+ publicDir: false,
18
+ build: {
19
+ lib: {
20
+ entry
21
+ },
22
+ outDir
23
+ },
24
+ plugins: [genComponentStyle(), replace((format, args) => `..${args[1]}/index.${format}.js`)]
25
+ };
26
+ console.log(`build ${component} begin`);
27
+ await buildCommon({ ...options, config, type: 'lib' });
28
+ console.log(`build ${component} success`);
29
+ // const cssEntry = `./components/${component}/src/${component}.scss`;
30
+ // if(!existsSync(cssEntry)) {
31
+ // return;
32
+ // }
33
+ // await buildCss({...options,entry: cssEntry, outfile: `./package/${component}/index.css` });
34
+ });
35
+ }
36
+ ;
@@ -0,0 +1,11 @@
1
+ import { build } from "esbuild";
2
+ import { sassPlugin } from 'esbuild-sass-plugin';
3
+ export async function buildCss(options) {
4
+ const { entry, outfile } = options;
5
+ await build({
6
+ entryPoints: [entry],
7
+ outfile,
8
+ bundle: true,
9
+ plugins: [sassPlugin()],
10
+ });
11
+ }
@@ -0,0 +1,16 @@
1
+ import { buildCommon } from "./build.js";
2
+ import { generateTypes } from "../plugins/dts.js";
3
+ export async function buildLib(options) {
4
+ const { dts = false } = options;
5
+ const config = {
6
+ publicDir: false,
7
+ plugins: [
8
+ dts && generateTypes("./components", "./package/types")
9
+ ]
10
+ };
11
+ console.log(`build lib begin`);
12
+ await buildCommon({ ...options, config, type: 'lib' });
13
+ console.log(`build lib success`);
14
+ // await buildCss({...options, entry: "./components/index.scss", outfile: "./package/index.css"});
15
+ }
16
+ ;
@@ -0,0 +1,10 @@
1
+ import { build, mergeConfig, loadConfigFromFile } from 'vite';
2
+ import { getViteConfig } from '../common/get-vite-config.js';
3
+ export async function buildCommon(options) {
4
+ const { configFile, config, type } = options;
5
+ const viteConfig = await loadConfigFromFile({ command: 'build', mode: 'production' }, configFile);
6
+ const defaultConfig = await getViteConfig(type);
7
+ const libConfig = mergeConfig(mergeConfig(defaultConfig, viteConfig ? viteConfig.config : {}), config);
8
+ await build(libConfig);
9
+ }
10
+ ;
@@ -0,0 +1,54 @@
1
+ import { generateApp } from "../common/generate-app.js";
2
+ import inquirer from "inquirer";
3
+ const prompt = inquirer.createPromptModule();
4
+ const questions = [
5
+ {
6
+ type: "input",
7
+ name: "name",
8
+ message: "What is your project name?",
9
+ default: "my-project",
10
+ },
11
+ {
12
+ type: "list",
13
+ name: "type",
14
+ message: "What type of project is this?",
15
+ choices: ["app", "lib"],
16
+ },
17
+ {
18
+ type: "list",
19
+ name: "platform",
20
+ message: "What platform of project is this?",
21
+ choices: ["pc", "mobile"],
22
+ when: (response) => {
23
+ const { type } = response;
24
+ return type === 'app';
25
+ }
26
+ },
27
+ {
28
+ type: "checkbox",
29
+ name: "formats",
30
+ message: "What output format of project is this?",
31
+ choices: ["es", "umd", "systemjs"],
32
+ default: ["es", "umd"],
33
+ when: (response) => {
34
+ const { type } = response;
35
+ return type === 'lib';
36
+ }
37
+ },
38
+ {
39
+ type: "list",
40
+ name: "format",
41
+ message: "What output format of project is this?",
42
+ choices: ["es", "umd", "systemjs"],
43
+ default: ["es"],
44
+ when: (response) => {
45
+ const { type } = response;
46
+ return type === 'app';
47
+ }
48
+ }
49
+ ];
50
+ export async function createApp() {
51
+ const response = await prompt(questions);
52
+ generateApp(response);
53
+ }
54
+ ;
@@ -0,0 +1,23 @@
1
+ import { createServer, mergeConfig } from 'vite';
2
+ import { getViteConfig } from '../common/get-vite-config.js';
3
+ export const devServe = async (options) => {
4
+ const { port = 1337, host = true } = options;
5
+ const config = await getViteConfig();
6
+ const devConfig = mergeConfig({
7
+ configFile: false,
8
+ mode: 'dev',
9
+ define: {
10
+ __VUE_OPTIONS_API__: 'true',
11
+ __VUE_PROD_DEVTOOLS__: 'true',
12
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'true'
13
+ },
14
+ server: {
15
+ port,
16
+ host,
17
+ hmr: true
18
+ }
19
+ }, config);
20
+ const server = await createServer(devConfig);
21
+ await server.listen();
22
+ server.printUrls();
23
+ };
@@ -0,0 +1,16 @@
1
+ import { preview, mergeConfig } from 'vite';
2
+ import { getViteConfig } from '../common/get-vite-config.js';
3
+ export const previewServe = async (options) => {
4
+ const { port = 4137, host = true } = options;
5
+ const config = await getViteConfig();
6
+ const previewConfig = mergeConfig({
7
+ configFile: false,
8
+ preview: {
9
+ port,
10
+ host,
11
+ open: true
12
+ }
13
+ }, config);
14
+ const server = await preview(previewConfig);
15
+ server.printUrls();
16
+ };
@@ -0,0 +1,18 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { join, dirname } from 'node:path';
4
+ function findRootDir(dir) {
5
+ if (existsSync(join(dir, 'farris.config.js'))) {
6
+ return dir;
7
+ }
8
+ const parentDir = dirname(dir);
9
+ if (dir === parentDir) {
10
+ return dir;
11
+ }
12
+ return findRootDir(parentDir);
13
+ }
14
+ export const getDirname = (url) => fileURLToPath(new URL('.', url));
15
+ // Root paths
16
+ export const CWD = process.cwd();
17
+ export const ROOT = findRootDir(CWD);
18
+ export const FAARIS_CONFIG_FILE = join(CWD, 'farris.config.mjs');
@@ -0,0 +1,44 @@
1
+ import { resolve } from 'path';
2
+ import { createRequire } from "node:module";
3
+ import { CWD, getDirname } from './constant.js';
4
+ import { getVersion } from "./get-version.js";
5
+ const require = createRequire(import.meta.url);
6
+ const { copySync, readFileSync, writeFileSync } = require("fs-extra");
7
+ const Array2String = (arr) => {
8
+ return `[${arr.reduce((acc, cur, index) => {
9
+ acc = index === 1 ? "'" + acc + "'" : acc;
10
+ acc += `,'${cur}'`;
11
+ return acc;
12
+ })}]`;
13
+ };
14
+ const copyTemplate = (template, target) => {
15
+ const templatePath = resolve(getDirname(import.meta.url), '../../templates', template);
16
+ const targetPath = resolve(CWD, target);
17
+ console.log(templatePath, targetPath);
18
+ copySync(templatePath, targetPath);
19
+ };
20
+ const replaceContent = (path, args) => {
21
+ let content = readFileSync(path, 'utf-8');
22
+ Object.keys(args).forEach((key) => {
23
+ const regexp = new RegExp(`<%= ${key} %>`, 'g');
24
+ const value = Array.isArray(args[key]) ? Array2String(args[key]) : args[key];
25
+ content = content.replace(regexp, value);
26
+ });
27
+ writeFileSync(path, content);
28
+ };
29
+ export const generateApp = (options) => {
30
+ const { name, type, formats, format, platform } = options;
31
+ const template = type === 'lib' ? 'lib' : platform;
32
+ copyTemplate(template, name);
33
+ const replaceFiles = [
34
+ 'package.json',
35
+ 'farris.config.mjs',
36
+ 'index.html'
37
+ ];
38
+ const cliVersion = getVersion();
39
+ replaceFiles.forEach(replaceFile => {
40
+ replaceContent(resolve(CWD, name, replaceFile), { name, formats, format, platform, cliVersion });
41
+ });
42
+ console.log(`cd ${name}`);
43
+ console.log(`npm install or yarn`);
44
+ };
@@ -0,0 +1,9 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { resolve } from 'node:path';
3
+ import { CWD } from "../common/constant.js";
4
+ export const getDependencies = () => {
5
+ const pkg = readFileSync(resolve(CWD, 'package.json'), 'utf-8');
6
+ const packageJson = JSON.parse(pkg);
7
+ const { dependencies, peerDependencies } = packageJson;
8
+ return [...Object.keys(dependencies || {}), ...Object.keys(peerDependencies || {})];
9
+ };
@@ -0,0 +1,11 @@
1
+ import { pathToFileURL } from 'node:url';
2
+ import { FAARIS_CONFIG_FILE } from './constant.js';
3
+ async function getFarrisConfigAsync() {
4
+ try {
5
+ return (await import(pathToFileURL(FAARIS_CONFIG_FILE).href)).default;
6
+ }
7
+ catch (err) {
8
+ return {};
9
+ }
10
+ }
11
+ export { getFarrisConfigAsync };
@@ -0,0 +1,6 @@
1
+ import { createRequire } from 'node:module';
2
+ const require = createRequire(import.meta.url);
3
+ const packageJson = require('../../package.json');
4
+ export const getVersion = () => {
5
+ return packageJson.version;
6
+ };
@@ -0,0 +1,38 @@
1
+ import { mergeConfig } from 'vite';
2
+ import { getFarrisConfigAsync } from './get-farris-config.js';
3
+ import { getDependencies } from '../common/get-dependencies.js';
4
+ const formatFarrisConfig = (farrisConfig, type) => {
5
+ const { lib, format, minify = true, externals = { include: [], exclude: [] }, externalDependencies, plugins, alias } = farrisConfig;
6
+ const dependencies = externalDependencies ? getDependencies() : [];
7
+ let external = externals.include ? [...externals.include, ...dependencies] : dependencies;
8
+ external = external.filter(item => !externals.exclude?.includes(item));
9
+ format && (process.env.FARRIS_FORMAT = format);
10
+ const viteConfig = {
11
+ build: {
12
+ minify,
13
+ lib: type === 'lib' ? lib : undefined,
14
+ rollupOptions: {
15
+ output: {
16
+ format
17
+ },
18
+ external
19
+ }
20
+ },
21
+ plugins,
22
+ resolve: {
23
+ alias
24
+ }
25
+ };
26
+ return viteConfig;
27
+ };
28
+ const formatViteConfig = async (type) => {
29
+ const { viteConfig = {}, ...farrisConfig } = await getFarrisConfigAsync();
30
+ const customViteConfig = formatFarrisConfig(farrisConfig, type);
31
+ return mergeConfig(customViteConfig, viteConfig);
32
+ };
33
+ const getViteConfig = async (type = 'app') => {
34
+ const viteConfig = await formatViteConfig(type);
35
+ const { default: defaultViteConfig } = await import(`../config/vite-${type}.js`);
36
+ return mergeConfig(defaultViteConfig, viteConfig);
37
+ };
38
+ export { getViteConfig };
@@ -0,0 +1,14 @@
1
+ import vue from '@vitejs/plugin-vue';
2
+ import vueJsx from '@vitejs/plugin-vue-jsx';
3
+ import { CWD } from '../common/constant.js';
4
+ import { htmlSystemPlugin } from '../plugins/html-system.js';
5
+ export default {
6
+ root: CWD,
7
+ base: './',
8
+ // logLevel: 'silent',
9
+ plugins: [
10
+ vue(),
11
+ vueJsx(),
12
+ process.env.FARRIS_FORMAT === 'systemjs' && htmlSystemPlugin()
13
+ ]
14
+ };
@@ -0,0 +1,35 @@
1
+ import vue from '@vitejs/plugin-vue';
2
+ import vueJsx from '@vitejs/plugin-vue-jsx';
3
+ import { CWD } from '../common/constant.js';
4
+ import { resolve } from "node:path";
5
+ export default {
6
+ root: CWD,
7
+ base: './',
8
+ logLevel: 'silent',
9
+ plugins: [vue(), vueJsx()],
10
+ build: {
11
+ lib: {
12
+ entry: resolve(CWD, `./src/main.ts`),
13
+ fileName: "index",
14
+ formats: ["es", "systemjs"],
15
+ },
16
+ outDir: resolve(CWD, `./lib`),
17
+ rollupOptions: {
18
+ external: [],
19
+ output: {
20
+ exports: "named",
21
+ globals: (id) => {
22
+ if (id.includes('@components')) {
23
+ const name = id.split('/').pop() || '';
24
+ return name.slice(0, 1).toUpperCase() + name.slice(1);
25
+ }
26
+ const map = {
27
+ vue: "Vue",
28
+ '@farris/mobile-ui-vue': 'FarrisVue'
29
+ };
30
+ return map[id];
31
+ }
32
+ }
33
+ },
34
+ }
35
+ };
package/lib/index.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { getVersion } from "./common/get-version.js";
4
+ const program = new Command();
5
+ program.version(`@farris/cli ${getVersion()}`);
6
+ program
7
+ .command('build')
8
+ .description('构建')
9
+ .option('-c --configFile [configFile]', 'config file path')
10
+ .action(async (options) => {
11
+ const { buildCommon } = await import('./commands/build.js');
12
+ return buildCommon(options);
13
+ });
14
+ program
15
+ .command('build-lib')
16
+ .description('构建')
17
+ .option('-c --configFile [configFile]', 'config file path')
18
+ .option('-d --dts', 'dts')
19
+ .action(async (options) => {
20
+ const { buildLib } = await import('./commands/build-lib.js');
21
+ return buildLib(options);
22
+ });
23
+ program
24
+ .command('build-components')
25
+ .description('构建')
26
+ .option('-c --configFile [configFile]', 'config file path')
27
+ .action(async (options) => {
28
+ const { buildComponents } = await import('./commands/build-components.js');
29
+ return buildComponents(options);
30
+ });
31
+ program
32
+ .command('create-app')
33
+ .description('新建 App 模板')
34
+ .action(async () => {
35
+ const { createApp } = await import('./commands/create-app.js');
36
+ return createApp();
37
+ });
38
+ program
39
+ .command('dev')
40
+ .description('创建 Dev Server')
41
+ .option('-p --port [port]', 'Server Port')
42
+ .action(async (options) => {
43
+ const { devServe } = await import('./commands/dev-serve.js');
44
+ return devServe(options);
45
+ });
46
+ program
47
+ .command('preview')
48
+ .description('创建 Preview Server')
49
+ .option('-p --port [port]', 'Server Port')
50
+ .action(async (options) => {
51
+ const { previewServe } = await import('./commands/preview-serve.js');
52
+ return previewServe(options);
53
+ });
54
+ program.parse();
@@ -0,0 +1,8 @@
1
+ import dts from "vite-plugin-dts";
2
+ export function generateTypes(entry, outDir) {
3
+ return dts({
4
+ entryRoot: entry,
5
+ outDir
6
+ });
7
+ }
8
+ ;
@@ -0,0 +1,43 @@
1
+ const NotStyleComponents = ['designer-canvas', 'dynamic-view', 'dynamic-resolver', 'common'];
2
+ const getComponentStyle = (imports) => {
3
+ const components = imports
4
+ .filter(path => {
5
+ return path.startsWith('@components/') && !NotStyleComponents.find(notStylecomponent => path.includes(notStylecomponent));
6
+ })
7
+ .filter((item, index, array) => {
8
+ return array.indexOf(item) === index;
9
+ })
10
+ .map(name => {
11
+ const paths = name.split('/');
12
+ return {
13
+ name: paths[1],
14
+ path: `../${paths[1]}/index.css`
15
+ };
16
+ });
17
+ components.push({
18
+ name: 'components',
19
+ path: `./index.css`
20
+ });
21
+ const template = `${components.map(component => {
22
+ const { path } = component;
23
+ return `import '${path}';`;
24
+ }).join('\n')}
25
+ `;
26
+ return template;
27
+ };
28
+ export function genComponentStyle() {
29
+ return {
30
+ name: 'farris-gen-component-style',
31
+ renderChunk(code, chunk) {
32
+ const { imports } = chunk;
33
+ const template = getComponentStyle(imports);
34
+ this.emitFile({
35
+ type: 'asset',
36
+ fileName: 'style.js',
37
+ source: template
38
+ });
39
+ return code;
40
+ }
41
+ };
42
+ }
43
+ ;
@@ -0,0 +1,11 @@
1
+ export const htmlSystemPlugin = () => {
2
+ return {
3
+ name: 'html-transform-system',
4
+ transformIndexHtml(html) {
5
+ const regexp = /<script.*type="module".*src="(.*?)"><\/script>/;
6
+ return html.replace(regexp, (str, p1) => `
7
+ <script src="https://cdn.bootcdn.net/ajax/libs/systemjs/6.15.1/system.js"></script>
8
+ <script >System.import("${p1}");</script>`);
9
+ }
10
+ };
11
+ };
@@ -0,0 +1,13 @@
1
+ export function replace(path) {
2
+ return {
3
+ name: 'farris-replace',
4
+ renderChunk(code, chunk) {
5
+ const fileNames = chunk.fileName.split('.');
6
+ const format = fileNames[fileNames.length - 2];
7
+ return code.replace(/@components(\/\w+)/g, (...args) => {
8
+ return path(format, args);
9
+ });
10
+ }
11
+ };
12
+ }
13
+ ;
package/package.json CHANGED
@@ -1,26 +1,38 @@
1
1
  {
2
2
  "name": "@farris/cli",
3
- "version": "1.0.27",
4
- "description": "Farris command line interface",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
3
+ "private": false,
4
+ "version": "2.0.0-beta.7",
5
+ "type": "module",
6
+ "typings": "lib/index.d.ts",
7
+ "bin": {
8
+ "farris-cli": "./bin/index.js"
8
9
  },
9
- "repository": {
10
- "type": "git",
11
- "url": "https://git.iec.io/webadp/farris-cli.git"
10
+ "engines": {
11
+ "node": ">=16.0.0"
12
12
  },
13
- "keywords": [
14
- "Farris",
15
- "CLI"
16
- ],
17
- "bin": {
18
- "farris": "ci/cli.js"
13
+ "scripts": {
14
+ "build": "rimraf ./lib && tsc"
19
15
  },
20
- "author": "Sagi Chen",
21
- "license": "ISC",
16
+ "files": [
17
+ "lib",
18
+ "templates",
19
+ "bin.js"
20
+ ],
22
21
  "dependencies": {
23
- "lerna": "^4.0.0",
24
- "moment": "^2.29.3"
22
+ "@types/inquirer": "^9.0.7",
23
+ "@vitejs/plugin-vue": "^4.0.0",
24
+ "@vitejs/plugin-vue-jsx": "^3.0.0",
25
+ "commander": "^9.4.0",
26
+ "esbuild-sass-plugin": "^3.3.1",
27
+ "inquirer": "^9.3.0",
28
+ "typescript": "^4.6.4",
29
+ "vite": "^4.4.1",
30
+ "vite-plugin-dts": "^3.9.1",
31
+ "vite-plugin-html": "^3.2.2"
32
+ },
33
+ "devDependencies": {
34
+ "@types/inquirer": "^9.0.7",
35
+ "rimraf": "^5.0.7",
36
+ "vue": "^3.2.37"
25
37
  }
26
38
  }
@@ -0,0 +1,15 @@
1
+ /* eslint-env node */
2
+ require('@rushstack/eslint-patch/modern-module-resolution')
3
+
4
+ module.exports = {
5
+ root: true,
6
+ 'extends': [
7
+ 'plugin:vue/vue3-essential',
8
+ 'eslint:recommended',
9
+ '@vue/eslint-config-typescript',
10
+ '@vue/eslint-config-prettier/skip-formatting'
11
+ ],
12
+ parserOptions: {
13
+ ecmaVersion: 'latest'
14
+ }
15
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/prettierrc",
3
+ "semi": false,
4
+ "tabWidth": 2,
5
+ "singleQuote": true,
6
+ "printWidth": 100,
7
+ "trailingComma": "none"
8
+ }
@@ -0,0 +1,35 @@
1
+ import { fileURLToPath, URL } from 'node:url';
2
+
3
+ export default {
4
+ // 库模式配置
5
+ lib: {
6
+ // 入口 默认值 './src/main.ts'
7
+ entry: './packages/index.ts',
8
+ // 库名称
9
+ name: "<%= name %>",
10
+ // 输出文件名
11
+ fileName: "index",
12
+ // 输出文件格式 默认值 ["es", 'systemjs']
13
+ formats: <%= formats %>,
14
+ },
15
+ // 输出目录 App模式默认值 './dist' Lib模式 './lib'
16
+ // outDir: fileURLToPath(new URL('./dist', import.meta.url)),
17
+ // 最小化 默认值 true
18
+ minify: true,
19
+ // 外部依赖排除项 默认值 { include: [], exclude: [] }
20
+ // externals: {
21
+ // include: [],
22
+ // exclude: []
23
+ // },
24
+ // 是否排除 package.json 中 dependencies和 peerDependencies 依赖的包; App模式默认值 false Lib模式默认值 true
25
+ externalDependencies: true,
26
+ // 路径别名 默认值 null
27
+ alias: [
28
+ { find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
29
+ { find: '@packages', replacement: fileURLToPath(new URL('./packages', import.meta.url)) },
30
+ ],
31
+ // 插件 默认值 [vue(), vueJsx()] 不要重复添加
32
+ // plugins: [],
33
+ // viteConfig 配置项
34
+ viteConfig: {}
35
+ }
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Vite App</title>
7
+ </head>
8
+ <body>
9
+ <div id="app"></div>
10
+ <script type="module" src="/src/main.ts"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "<%= name %>",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "main": "./dist/index.umd.js",
7
+ "module": "./dist/index.js",
8
+ "scripts": {
9
+ "dev": "farris-cli dev",
10
+ "build": "farris-cli build-lib",
11
+ "preview": "farris-cli preview",
12
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
13
+ "format": "prettier --write src/"
14
+ },
15
+ "dependencies": {
16
+ "vue": "^3.4.29"
17
+ },
18
+ "devDependencies": {
19
+ "@farris/cli": "<%= cliVersion %>",
20
+ "@rushstack/eslint-patch": "^1.8.0",
21
+ "@vue/eslint-config-prettier": "^9.0.0",
22
+ "@vue/eslint-config-typescript": "^13.0.0",
23
+ "@vue/tsconfig": "^0.5.1",
24
+ "eslint": "^8.57.0",
25
+ "eslint-plugin-vue": "^9.23.0",
26
+ "prettier": "^3.2.5",
27
+ "typescript": "~5.4.0"
28
+ }
29
+ }