Browse Source

KERNEL-14316 fix: bundle打包

es6
Treecat 2 years ago
parent
commit
57a5223a39
  1. 10
      package.json
  2. 10
      packages/fineui/package.json
  3. 13
      packages/fineui/src/bundle.js
  4. 4
      packages/fineui/src/core/platform/web/index.js
  5. 6
      packages/fineui/src/index.js
  6. 76
      packages/fineui/webpack.prod.js

10
package.json

@ -9,25 +9,33 @@
"dev": "npm-run-all --parallel dev:*",
"dev:demo": "cd packages/demo && npm run dev",
"dev:fineui": "cd packages/fineui && npm run dev",
"static": "node script/code.static.js"
"build": "cd packages/fineui && npm run build"
},
"devDependencies": {
"@babel/cli": "^7.21.0",
"@babel/core": "^7.21.0",
"@babel/runtime": "^7.21.0",
"@fui/babel-preset-fineui": "^3.0.1",
"autoprefixer": "^10.4.14",
"babel-loader": "^9.1.2",
"babel-plugin-module-resolver": "^5.0.0",
"css-loader": "^6.7.3",
"fork-ts-checker-webpack-plugin": "^8.0.0",
"html-webpack-plugin": "^5.5.0",
"less": "^4.1.3",
"less-loader": "^11.1.0",
"mini-css-extract-plugin": "^2.7.5",
"npm-run-all": "^4.1.5",
"optimize-css-assets-webpack-plugin": "^6.0.1",
"postcss": "^8.4.21",
"style-loader": "^3.3.1",
"terser-webpack-plugin": "^5.3.7",
"typescript": "^4.9.5",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^5.75.0",
"webpack-bundle-analyzer": "^4.8.0",
"webpack-cli": "^5.0.1",
"circular-dependency-plugin": "^5.2.2",
"webpack-dev-server": "^4.11.1"
}
}

10
packages/fineui/package.json

@ -5,7 +5,11 @@
"main": "dist/fineui_without_conflict.min.js",
"module": "dist/es/index.js",
"types": "dist/type/index.d.ts",
"bin": {
"fui-cli": "./bin/cli/cli.js"
},
"sideEffects": [
"src/**/*.js",
"dist/es/core/*.js",
"dist/es/core/element/**/*.js",
"dist/es/core/platform/**/*.js",
@ -13,11 +17,9 @@
"dist/es/case/ztree/jquery.ztree.core-3.5.js",
"dist/es/case/ztree/jquery.ztree.excheck-3.5.js"
],
"bin": {
"fui-cli": "./bin/cli/cli.js"
},
"scripts": {
"dev": "babel src -d dist/es --config-file ./esm.babel.js -w"
"dev": "babel src -d dist/es --config-file ./esm.babel.js -w",
"build": "webpack --config=webpack.prod.js"
},
"repository": {
"type": "git",

13
packages/fineui/src/bundle.js

@ -1,4 +1,4 @@
import * as fineui from "./index";
import * as fuiExport from "./index";
import { shortcut, provider } from "@/core/5.inject";
import { _global } from "@/core/0.foundation";
import * as Decorators from "@/core/decorator";
@ -6,9 +6,10 @@ import * as Decorators from "@/core/decorator";
_global.BI = _global.BI || {};
_global.BI.Decorators = Decorators;
_global.Fix = fineui.Fix;
_global._ = fineui._;
Object.assign(_global, {
Fix: fuiExport.Fix,
_: fuiExport._,
$: fuiExport.$,
});
_global.$ = fineui.$;
Object.assign(_global.BI, fineui, { shortcut, provider });
Object.assign(_global.BI, fuiExport, { shortcut, provider });

4
packages/fineui/src/core/platform/web/index.js

@ -2,5 +2,5 @@ export * from "./detectElementResize";
export * from "./function";
export * from "./load";
import "./jquery/index";
import "./config";

6
packages/fineui/src/index.js

@ -1,7 +1,11 @@
// sideEffects
import "./polyfill";
import "./core/platform/web/jquery";
import "./core/system";
import "./core/element";
import "./core/platform";
import "./core/platform/web/jquery"
// 必须要等上面的准备好, 才初始化 config
import "./core/platform/web/config";
import _jquery from "jquery";

76
packages/fineui/webpack.prod.js

@ -1,21 +1,31 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const path = require("path");
const autoprefixer = require("autoprefixer");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const CircularDependencyPlugin = require("circular-dependency-plugin");
const childProcess = require("child_process");
function git(command) {
return childProcess.execSync(`git ${command}`).toString().trim();
}
module.exports = {
mode: 'production',
entry: './src/index.js',
devServer: {
port: 3000,
liveReload: true,
mode: "production",
entry: "./src/bundle.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].js",
},
devtool: 'hidden-source-map',
devtool: false,
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
loader: "babel-loader",
},
},
{
@ -23,22 +33,22 @@ module.exports = {
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
loader: "css-loader",
options: {
url: false,
},
},
{
loader: 'postcss-loader',
loader: "postcss-loader",
options: {
plugins: [autoprefixer],
},
},
{
loader: 'less-loader',
loader: "less-loader",
options: {
relativeUrls: false,
modifyVars: lessVariables,
// modifyVars: lessVariables,
},
},
],
@ -46,32 +56,26 @@ module.exports = {
],
},
resolve: {
extensions: ['.js', '.ts'],
extensions: [".js", ".ts"],
alias: {
'@': path.resolve(__dirname, '../src'),
"@": path.resolve(__dirname, "src"),
},
},
plugins: [
new MiniCssExtractPlugin({
path: dirs.DEST,
filename: '[name].css',
}),
new ForkTsCheckerWebpackPlugin({}),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/g,
cssProcessor: require('cssnano'),
cssProcessorPluginOptions: {
preset: [
'default',
{
discardComments: {
removeAll: true,
},
normalizeUnicode: false,
},
],
},
canPrint: true,
}),
new CircularDependencyPlugin(),
],
optimization: {
usedExports: false,
minimize: true,
minimizer: [
new TerserPlugin({
include: /\.js$/i,
}),
new webpack.BannerPlugin({
banner: `time: ${new Date().toLocaleString()}; branch: ${git(
"name-rev --name-only HEAD"
)} commit: ${git("rev-parse HEAD")}`,
}),
],
},
};

Loading…
Cancel
Save