mirror of
https://github.com/layui/layui.git
synced 2026-02-09 02:09:18 +08:00
chore: 基础优化 (#2927)
* chore: 优化模块入口文件 * style: 优化字体 * build: 优化局部构建流程 * chore: 优化代码格式
This commit is contained in:
6
.github/workflows/release-npm.yml
vendored
6
.github/workflows/release-npm.yml
vendored
@@ -9,10 +9,10 @@ jobs:
|
|||||||
publish-npm:
|
publish-npm:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 22
|
||||||
registry-url: https://registry.npmjs.org
|
registry-url: https://registry.npmjs.org
|
||||||
- run: npm publish
|
- run: npm publish
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -3,9 +3,6 @@
|
|||||||
"description": "Classic Web UI Component Library",
|
"description": "Classic Web UI Component Library",
|
||||||
"version": "3.0.0-alpha.0",
|
"version": "3.0.0-alpha.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
|
||||||
"node": ">=20.17"
|
|
||||||
},
|
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"layui",
|
"layui",
|
||||||
"components",
|
"components",
|
||||||
@@ -38,8 +35,9 @@
|
|||||||
"dev": "node scripts/dev.mjs",
|
"dev": "node scripts/dev.mjs",
|
||||||
"serve": "serve tests/visual -p 3003 --cors -L -n",
|
"serve": "serve tests/visual -p 3003 --cors -L -n",
|
||||||
"build": "run-s clean:dist build:*",
|
"build": "run-s clean:dist build:*",
|
||||||
"build:css": "postcss src/css/index.css -o dist/css/layui.css",
|
"build:css": "postcss src/css/index.css -o dist/css/layui.css --verbose",
|
||||||
"build:js": "rollup -c",
|
"build:js": "rollup -c",
|
||||||
|
"build:dev": "cross-env RUN=true node scripts/dev-builder.mjs",
|
||||||
"format": "prettier --write --cache .",
|
"format": "prettier --write --cache .",
|
||||||
"format:check": "prettier --check --cache .",
|
"format:check": "prettier --check --cache .",
|
||||||
"lint": "eslint . --cache",
|
"lint": "eslint . --cache",
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ const DEST = process.env.DEST || 'dist';
|
|||||||
const outputDir = path.resolve(__dirname, `./${DEST}`);
|
const outputDir = path.resolve(__dirname, `./${DEST}`);
|
||||||
const isDevMode = process.env.MODE === 'dev';
|
const isDevMode = process.env.MODE === 'dev';
|
||||||
|
|
||||||
// config
|
// 插件配置
|
||||||
const options = {
|
const pluginsConfig = {
|
||||||
terser: {
|
terser: {
|
||||||
compress: {
|
compress: {
|
||||||
passes: 2, // 提高压缩率,默认 1
|
passes: 2, // 提高压缩率,默认 1
|
||||||
@@ -65,14 +65,14 @@ const pushRollupConfig = (opts, callback) => {
|
|||||||
}),
|
}),
|
||||||
resolve(),
|
resolve(),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
babel(options.babel),
|
babel(pluginsConfig.babel),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
// 开发模式不压缩
|
// 开发模式不压缩
|
||||||
if (opts.minify && !isDevMode) {
|
if (opts.minify && !isDevMode) {
|
||||||
config.output.plugins.push(
|
config.output.plugins.push(
|
||||||
terser(options.terser),
|
terser(pluginsConfig.terser),
|
||||||
banner({
|
banner({
|
||||||
comment: `/** ${version} | ${pkg.license} Licensed */`,
|
comment: `/** ${version} | ${pkg.license} Licensed */`,
|
||||||
}),
|
}),
|
||||||
|
|||||||
43
scripts/dev-builder.mjs
Normal file
43
scripts/dev-builder.mjs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* 生成开发包
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { spawn } from 'cross-spawn';
|
||||||
|
|
||||||
|
const DEST = 'tests/visual/assets/dist'; // 输出目录
|
||||||
|
const env = { ...process.env, DEST, MODE: 'dev' };
|
||||||
|
|
||||||
|
// 执行 postcss 子进程
|
||||||
|
export const postcss = (args = [], options = {}) => {
|
||||||
|
args = [
|
||||||
|
'src/css/index.css',
|
||||||
|
'-o',
|
||||||
|
`${DEST}/css/layui.css`,
|
||||||
|
'--verbose',
|
||||||
|
].concat(args);
|
||||||
|
options = {
|
||||||
|
env,
|
||||||
|
stdio: 'inherit',
|
||||||
|
...options,
|
||||||
|
};
|
||||||
|
|
||||||
|
return spawn('postcss', args, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 执行 rollup 子进程
|
||||||
|
export const rollup = (args = [], options = {}) => {
|
||||||
|
args = ['-c'].concat(args);
|
||||||
|
options = {
|
||||||
|
env,
|
||||||
|
stdio: 'inherit',
|
||||||
|
...options,
|
||||||
|
};
|
||||||
|
|
||||||
|
return spawn('rollup', args, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 是否执行子进程
|
||||||
|
if (env.RUN) {
|
||||||
|
postcss();
|
||||||
|
rollup();
|
||||||
|
}
|
||||||
@@ -6,9 +6,7 @@
|
|||||||
|
|
||||||
import { spawn } from 'cross-spawn';
|
import { spawn } from 'cross-spawn';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
import { rollup, postcss } from './dev-builder.mjs';
|
||||||
const DEST = 'tests/visual/assets/dist'; // 输出目录
|
|
||||||
const env = { ...process.env, DEST, MODE: 'dev' };
|
|
||||||
|
|
||||||
// 初始提示信息
|
// 初始提示信息
|
||||||
console.log(chalk.hex('#16b777').bold('🚀 Starting Layui development mode...'));
|
console.log(chalk.hex('#16b777').bold('🚀 Starting Layui development mode...'));
|
||||||
@@ -52,20 +50,13 @@ function pipeOutput(child, prefix) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 启动 rollup 和 postcss watcher
|
// 启动 postcss 和 rollup watcher
|
||||||
const rollup = spawn('rollup', ['-c', '-w'], {
|
const child_postcss = postcss(['-w'], {
|
||||||
|
stdio: 'pipe',
|
||||||
|
});
|
||||||
|
const child_rollup = rollup(['-w'], {
|
||||||
stdio: 'pipe',
|
stdio: 'pipe',
|
||||||
env,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const postcss = spawn(
|
pipeOutput(child_postcss, 'postcss');
|
||||||
'postcss',
|
pipeOutput(child_rollup, 'rollup');
|
||||||
['src/css/index.css', '-o', `${DEST}/css/layui.css`, '-w', '--verbose'],
|
|
||||||
{
|
|
||||||
stdio: 'pipe',
|
|
||||||
env,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
pipeOutput(rollup, 'rollup');
|
|
||||||
pipeOutput(postcss, 'postcss');
|
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ function overwriteArray(objValue, srcValue) {
|
|||||||
|
|
||||||
// 外部调用
|
// 外部调用
|
||||||
var laydate = {
|
var laydate = {
|
||||||
v: '5.7.0', // layDate 版本号
|
|
||||||
config: {
|
config: {
|
||||||
weekStart: 0, // 默认周日一周的开始
|
weekStart: 0, // 默认周日一周的开始
|
||||||
}, // 全局配置项
|
}, // 全局配置项
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ var ready = {
|
|||||||
|
|
||||||
// 默认内置方法。
|
// 默认内置方法。
|
||||||
var layer = {
|
var layer = {
|
||||||
v: '3.7.0',
|
|
||||||
ie: (function () {
|
ie: (function () {
|
||||||
// ie 版本
|
// ie 版本
|
||||||
var agent = navigator.userAgent.toLowerCase();
|
var agent = navigator.userAgent.toLowerCase();
|
||||||
|
|||||||
@@ -1089,5 +1089,11 @@ Class.prototype.throttle = function (func, wait) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const layui = new Class();
|
const layui = new Class();
|
||||||
export default layui;
|
|
||||||
|
// 阻止 layui.use 加载内部模块
|
||||||
|
layui.all = true;
|
||||||
|
layui['layui.all'] = 'layui.all';
|
||||||
|
|
||||||
|
// export
|
||||||
|
export { layui, layui as default };
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/** 图标字体 **/
|
/** 图标字体 **/
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "layui-icon";
|
font-family: "layui-icon";
|
||||||
src: url("iconfont.woff") format("woff");
|
src: url("iconfont.woff2") format("woff2");
|
||||||
}
|
}
|
||||||
|
|
||||||
.layui-icon {
|
.layui-icon {
|
||||||
|
|||||||
Binary file not shown.
BIN
src/css/modules/iconfont.woff2
Normal file
BIN
src/css/modules/iconfont.woff2
Normal file
Binary file not shown.
@@ -38,8 +38,8 @@
|
|||||||
|
|
||||||
/* 字体 */
|
/* 字体 */
|
||||||
--lay-font-family:
|
--lay-font-family:
|
||||||
-apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
|
-apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", "PingFang SC",
|
||||||
"Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
"Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
--lay-font-monospace: "Courier New", Consolas, "Lucida Console", monospace;
|
--lay-font-monospace: "Courier New", Consolas, "Lucida Console", monospace;
|
||||||
|
|
||||||
/* 间距 */
|
/* 间距 */
|
||||||
|
|||||||
@@ -36,10 +36,8 @@ import { flow } from './components/flow.js';
|
|||||||
import { util } from './components/util.js';
|
import { util } from './components/util.js';
|
||||||
import { code } from './components/code.js';
|
import { code } from './components/code.js';
|
||||||
|
|
||||||
layui.all = true;
|
// 兼容 v2
|
||||||
layui['layui.all'] = 'layui.all'; // 阻止 layui.use 加载内部模块
|
window.layui = layui;
|
||||||
|
|
||||||
// 兼容处理
|
|
||||||
window.lay = lay;
|
window.lay = lay;
|
||||||
window.layer = layer;
|
window.layer = layer;
|
||||||
layui.$ = jquery;
|
layui.$ = jquery;
|
||||||
|
|||||||
@@ -2,13 +2,8 @@
|
|||||||
* Layui ESM 入口
|
* Layui ESM 入口
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { layui } from './core/layui.js';
|
|
||||||
|
|
||||||
layui.all = true;
|
|
||||||
layui['layui.all'] = 'layui.all'; // 阻止 layui.use 加载内部模块
|
|
||||||
|
|
||||||
// 导出核心模块
|
// 导出核心模块
|
||||||
export { layui };
|
export { layui } from './core/layui.js';
|
||||||
export { lay } from './core/lay.js';
|
export { lay } from './core/lay.js';
|
||||||
export { laytpl } from './core/laytpl.js';
|
export { laytpl } from './core/laytpl.js';
|
||||||
export { i18n } from './core/i18n.js';
|
export { i18n } from './core/i18n.js';
|
||||||
|
|||||||
5
tests/visual/assets/dist/css/layui.css
vendored
5
tests/visual/assets/dist/css/layui.css
vendored
File diff suppressed because one or more lines are too long
2
tests/visual/assets/dist/css/layui.css.map
vendored
2
tests/visual/assets/dist/css/layui.css.map
vendored
File diff suppressed because one or more lines are too long
14
tests/visual/assets/dist/layui.esm.js
vendored
14
tests/visual/assets/dist/layui.esm.js
vendored
@@ -1016,6 +1016,10 @@ Class$g.prototype.throttle = function (func, wait) {
|
|||||||
};
|
};
|
||||||
const layui = new Class$g();
|
const layui = new Class$g();
|
||||||
|
|
||||||
|
// 阻止 layui.use 加载内部模块
|
||||||
|
layui.all = true;
|
||||||
|
layui['layui.all'] = 'layui.all';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lay
|
* lay
|
||||||
* 基础模块
|
* 基础模块
|
||||||
@@ -14309,8 +14313,6 @@ function overwriteArray(objValue, srcValue) {
|
|||||||
|
|
||||||
// 外部调用
|
// 外部调用
|
||||||
var laydate = {
|
var laydate = {
|
||||||
v: '5.7.0',
|
|
||||||
// layDate 版本号
|
|
||||||
config: {
|
config: {
|
||||||
weekStart: 0 // 默认周日一周的开始
|
weekStart: 0 // 默认周日一周的开始
|
||||||
},
|
},
|
||||||
@@ -16995,7 +16997,6 @@ var ready = {
|
|||||||
|
|
||||||
// 默认内置方法。
|
// 默认内置方法。
|
||||||
var layer = {
|
var layer = {
|
||||||
v: '3.7.0',
|
|
||||||
ie: function () {
|
ie: function () {
|
||||||
// ie 版本
|
// ie 版本
|
||||||
var agent = navigator.userAgent.toLowerCase();
|
var agent = navigator.userAgent.toLowerCase();
|
||||||
@@ -32537,12 +32538,5 @@ function code(options, mode) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Layui ESM 入口
|
|
||||||
*/
|
|
||||||
|
|
||||||
layui.all = true;
|
|
||||||
layui['layui.all'] = 'layui.all'; // 阻止 layui.use 加载内部模块
|
|
||||||
|
|
||||||
export { $, component$9 as breadcrumb, component$2 as carousel, code, component$7 as collapse, component$c as colorpicker, component$e as component, component$e as componentBuilder, dropdown, component$6 as element, component as flow, form, i18n, $ as jquery, lay, laydate, layer, laypage, laytpl, layui, component$a as nav, component$8 as progress, component$1 as rate, component$d as slider, component$b as tab, table, component$5 as tabs, component$3 as transfer, component$4 as tree, treeTable, upload, util };
|
export { $, component$9 as breadcrumb, component$2 as carousel, code, component$7 as collapse, component$c as colorpicker, component$e as component, component$e as componentBuilder, dropdown, component$6 as element, component as flow, form, i18n, $ as jquery, lay, laydate, layer, laypage, laytpl, layui, component$a as nav, component$8 as progress, component$1 as rate, component$d as slider, component$b as tab, table, component$5 as tabs, component$3 as transfer, component$4 as tree, treeTable, upload, util };
|
||||||
//# sourceMappingURL=layui.esm.js.map
|
//# sourceMappingURL=layui.esm.js.map
|
||||||
|
|||||||
2
tests/visual/assets/dist/layui.esm.js.map
vendored
2
tests/visual/assets/dist/layui.esm.js.map
vendored
File diff suppressed because one or more lines are too long
12
tests/visual/assets/dist/layui.js
vendored
12
tests/visual/assets/dist/layui.js
vendored
@@ -1019,6 +1019,10 @@ var layui = (function () {
|
|||||||
};
|
};
|
||||||
const layui = new Class$g();
|
const layui = new Class$g();
|
||||||
|
|
||||||
|
// 阻止 layui.use 加载内部模块
|
||||||
|
layui.all = true;
|
||||||
|
layui['layui.all'] = 'layui.all';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lay
|
* lay
|
||||||
* 基础模块
|
* 基础模块
|
||||||
@@ -14312,8 +14316,6 @@ var layui = (function () {
|
|||||||
|
|
||||||
// 外部调用
|
// 外部调用
|
||||||
var laydate = {
|
var laydate = {
|
||||||
v: '5.7.0',
|
|
||||||
// layDate 版本号
|
|
||||||
config: {
|
config: {
|
||||||
weekStart: 0 // 默认周日一周的开始
|
weekStart: 0 // 默认周日一周的开始
|
||||||
},
|
},
|
||||||
@@ -16998,7 +17000,6 @@ var layui = (function () {
|
|||||||
|
|
||||||
// 默认内置方法。
|
// 默认内置方法。
|
||||||
var layer = {
|
var layer = {
|
||||||
v: '3.7.0',
|
|
||||||
ie: function () {
|
ie: function () {
|
||||||
// ie 版本
|
// ie 版本
|
||||||
var agent = navigator.userAgent.toLowerCase();
|
var agent = navigator.userAgent.toLowerCase();
|
||||||
@@ -32544,10 +32545,9 @@ var layui = (function () {
|
|||||||
* Layui IIFE 入口
|
* Layui IIFE 入口
|
||||||
*/
|
*/
|
||||||
|
|
||||||
layui.all = true;
|
|
||||||
layui['layui.all'] = 'layui.all'; // 阻止 layui.use 加载内部模块
|
|
||||||
|
|
||||||
// 兼容处理
|
// 兼容 v2
|
||||||
|
window.layui = layui;
|
||||||
window.lay = lay;
|
window.lay = lay;
|
||||||
window.layer = layer;
|
window.layer = layer;
|
||||||
layui.$ = jquery;
|
layui.$ = jquery;
|
||||||
|
|||||||
2
tests/visual/assets/dist/layui.js.map
vendored
2
tests/visual/assets/dist/layui.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user