1
This commit is contained in:
@@ -3,13 +3,19 @@ module.exports = {
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
modules: false,
|
||||
modules: 'auto', // 修改为 auto,让 webpack 自动处理模块格式
|
||||
targets: {
|
||||
browsers: ['>1%', 'last 2 versions', 'not ie <= 8']
|
||||
}
|
||||
}
|
||||
],
|
||||
'@vue/babel-preset-jsx'
|
||||
[
|
||||
'@vue/babel-preset-jsx',
|
||||
{
|
||||
// Vue 2 JSX 配置
|
||||
injectH: true // 自动注入 h 函数
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
|
||||
echo ================================
|
||||
echo 复制框架到 Demo 项目
|
||||
echo ================================
|
||||
echo.
|
||||
|
||||
REM 检查 dist 目录是否存在
|
||||
if not exist "dist\admin-framework.js" (
|
||||
echo ❌ 错误: dist\admin-framework.js 不存在
|
||||
echo 请先运行 build.bat 打包框架
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 创建 demo-project/src/libs 目录
|
||||
if not exist "demo-project\src\libs" (
|
||||
echo 📁 创建目录: demo-project\src\libs
|
||||
mkdir "demo-project\src\libs"
|
||||
)
|
||||
|
||||
REM 复制框架文件
|
||||
echo 📦 复制 dist\admin-framework.js 到 demo-project\src\libs\
|
||||
copy /Y "dist\admin-framework.js" "demo-project\src\libs\admin-framework.js" >nul
|
||||
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ 复制成功!
|
||||
echo.
|
||||
|
||||
REM 显示文件大小
|
||||
for %%A in (demo-project\src\libs\admin-framework.js) do (
|
||||
set SIZE=%%~zA
|
||||
set /a SIZE_KB=!SIZE! / 1024
|
||||
echo 📊 文件大小: !SIZE_KB! KB
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 📚 下一步:
|
||||
echo 1. 进入 demo-project 目录: cd demo-project
|
||||
echo 2. 启动开发服务器: npm run dev
|
||||
echo 3. 访问 http://localhost:8080
|
||||
echo.
|
||||
) else (
|
||||
echo ❌ 复制失败
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
pause
|
||||
|
||||
48
package-lock.json
generated
48
package-lock.json
generated
@@ -23,9 +23,12 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.0",
|
||||
"@babel/plugin-syntax-jsx": "^7.27.1",
|
||||
"@babel/plugin-transform-react-jsx": "^7.27.1",
|
||||
"@babel/preset-env": "^7.12.0",
|
||||
"autoprefixer": "^10.4.21",
|
||||
"babel-loader": "^8.2.0",
|
||||
"cross-env": "^10.1.0",
|
||||
"css-loader": "^5.0.0",
|
||||
"file-loader": "^6.2.0",
|
||||
"less": "^4.0.0",
|
||||
@@ -1217,6 +1220,26 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-transform-react-jsx": {
|
||||
"version": "7.27.1",
|
||||
"resolved": "https://registry.npmmirror.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.27.1.tgz",
|
||||
"integrity": "sha512-2KH4LWGSrJIkVf5tSiBFYuXDAoWRq2MMwgivCf+93dd0GQi8RXLjKA/0EvRnVV5G0hrHczsquXuD01L8s6dmBw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/helper-annotate-as-pure": "^7.27.1",
|
||||
"@babel/helper-module-imports": "^7.27.1",
|
||||
"@babel/helper-plugin-utils": "^7.27.1",
|
||||
"@babel/plugin-syntax-jsx": "^7.27.1",
|
||||
"@babel/types": "^7.27.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-transform-regenerator": {
|
||||
"version": "7.28.4",
|
||||
"resolved": "https://registry.npmmirror.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.28.4.tgz",
|
||||
@@ -1791,6 +1814,13 @@
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@epic-web/invariant": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/@epic-web/invariant/-/invariant-1.0.0.tgz",
|
||||
"integrity": "sha512-lrTPqgvfFQtR/eY/qkIzp98OGdNJu0m5ji3q/nJI8v3SXkRKEnWiOxMmbvcSoAIzv/cGiuvRy57k4suKQSAdwA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@jridgewell/gen-mapping": {
|
||||
"version": "0.3.13",
|
||||
"resolved": "https://registry.npmmirror.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||
@@ -2819,6 +2849,24 @@
|
||||
"@cropper/utils": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-env": {
|
||||
"version": "10.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/cross-env/-/cross-env-10.1.0.tgz",
|
||||
"integrity": "sha512-GsYosgnACZTADcmEyJctkJIoqAhHjttw7RsFrVoJNXbsWWqaq6Ym+7kZjq6mS45O0jij6vtiReppKQEtqWy6Dw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@epic-web/invariant": "^1.0.0",
|
||||
"cross-spawn": "^7.0.6"
|
||||
},
|
||||
"bin": {
|
||||
"cross-env": "dist/bin/cross-env.js",
|
||||
"cross-env-shell": "dist/bin/cross-env-shell.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||
|
||||
@@ -37,9 +37,12 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.0",
|
||||
"@babel/plugin-syntax-jsx": "^7.27.1",
|
||||
"@babel/plugin-transform-react-jsx": "^7.27.1",
|
||||
"@babel/preset-env": "^7.12.0",
|
||||
"autoprefixer": "^10.4.21",
|
||||
"babel-loader": "^8.2.0",
|
||||
"cross-env": "^10.1.0",
|
||||
"css-loader": "^5.0.0",
|
||||
"file-loader": "^6.2.0",
|
||||
"less": "^4.0.0",
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
const { VueLoaderPlugin } = require('vue-loader')
|
||||
const TerserPlugin = require('terser-webpack-plugin')
|
||||
|
||||
module.exports = {
|
||||
mode: 'production', // 明确指定生产模式
|
||||
target: 'web', // 明确指定浏览器环境
|
||||
entry: './src/index.js',
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
@@ -13,6 +15,7 @@ module.exports = {
|
||||
libraryTarget: 'umd',
|
||||
libraryExport: 'default',
|
||||
globalObject: 'typeof self !== \'undefined\' ? self : this',
|
||||
umdNamedDefine: true, // 为 UMD 模块添加名称
|
||||
clean: true // 构建前清理 dist 目录
|
||||
},
|
||||
externals: {
|
||||
@@ -56,7 +59,26 @@ module.exports = {
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel-loader',
|
||||
exclude: /node_modules/
|
||||
exclude: /node_modules/,
|
||||
options: {
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
modules: 'auto', // 修改为 auto,让 webpack 自动处理模块格式
|
||||
targets: {
|
||||
browsers: ['>1%', 'last 2 versions', 'not ie <= 8']
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'@vue/babel-preset-jsx',
|
||||
{
|
||||
injectH: true
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
@@ -146,7 +168,7 @@ module.exports = {
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [
|
||||
new (require('terser-webpack-plugin'))({
|
||||
new TerserPlugin({
|
||||
terserOptions: {
|
||||
format: {
|
||||
comments: /^!|@preserve|@license|@cc_on|admin-framework|作者/i // 保留特殊注释
|
||||
|
||||
Reference in New Issue
Block a user