From 5a41a24ecaaeca53713a41098f729a4b8ebef416 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 6 Jan 2022 00:06:06 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../button.linear.segment.js | 0 .../linear.segment.js | 0 src/core/{ => controller}/popper.js | 0 webpack/attachments.js | 10 ++- webpack/components.js | 41 ++++++++++++ webpack/webpack.prod.js | 64 ++++++++++++------- 6 files changed, 91 insertions(+), 24 deletions(-) rename src/case/{linersegment => linearsegment}/button.linear.segment.js (100%) rename src/case/{linersegment => linearsegment}/linear.segment.js (100%) rename src/core/{ => controller}/popper.js (100%) create mode 100644 webpack/components.js diff --git a/src/case/linersegment/button.linear.segment.js b/src/case/linearsegment/button.linear.segment.js similarity index 100% rename from src/case/linersegment/button.linear.segment.js rename to src/case/linearsegment/button.linear.segment.js diff --git a/src/case/linersegment/linear.segment.js b/src/case/linearsegment/linear.segment.js similarity index 100% rename from src/case/linersegment/linear.segment.js rename to src/case/linearsegment/linear.segment.js diff --git a/src/core/popper.js b/src/core/controller/popper.js similarity index 100% rename from src/core/popper.js rename to src/core/controller/popper.js diff --git a/webpack/attachments.js b/webpack/attachments.js index 52d9b568b..74c998484 100644 --- a/webpack/attachments.js +++ b/webpack/attachments.js @@ -41,7 +41,14 @@ const basicAttachmentMap = { router: sync([ "src/router/**/*.js", ]), - 'core_without_normalize': sync( + core_without_platform: sync([ + lodashJs, + "src/core/**/*.js", + "src/data/**/*.js", + "!src/core/platform/**/*.js", + "!src/core/controller/**/*.js", + ]), + core_without_normalize: sync( ["src/less/core/**/*.less", "src/less/theme/**/*.less", "!src/less/core/normalize.less", "!src/less/core/normalize2.less"], ), resource: sync(["src/less/resource/**/*.less"]), @@ -211,6 +218,7 @@ module.exports = { fineuiWithoutJqueryAndPolyfillJs: uniq(fineuiWithoutJqueryAndPolyfillJs), utils: uniq(basicAttachmentMap.utils), demo: uniq(demo), + coreWithoutPlatform: uniq(basicAttachmentMap.core_without_platform), coreJs: uniq(coreJs), resource: uniq((resource)), config: uniq(config), diff --git a/webpack/components.js b/webpack/components.js new file mode 100644 index 000000000..6548fa3f1 --- /dev/null +++ b/webpack/components.js @@ -0,0 +1,41 @@ +const grunt = require("grunt"); + +function uniq (names) { + return [...new Set(names)]; +} + +function sync (patterns) { + return uniq(grunt.file.expand({filter: path => !new RegExp(/__test__/g).test(path)}, patterns)).map(name => `./${name}`); +} + +const basicAttachmentMap = { + single: sync(["src/base/single/**/*.js"]), + button_group: sync(["src/base/combination/group.button.js"]), + buttons: sync(["src/case/button/**/*.js"]), + combos: sync(["src/case/combo/**/*.js"]), + editors: sync(["src/case/editor/**/*.js"]), + triggers: sync(["src/case/trigger/**/*.js"]), + calendar: sync(["src/case/calendar/**/*.js"]), + color_chooser: sync(["src/case/colorchooser/**/*.js"]), + segment: sync(["src/case/segment/**/*.js"]), + linear_segment: sync(["src/case/linearsegment/**/*.js"]), + date: sync(["src/widget/date/**/*.js"]), + down_list: sync(["src/widget/downlist/**/*.js"]), + text_value_down_list_combo: sync(["src/widget/textvaluedownlistcombo/**/*.js"]) +}; + +module.exports = { + single: basicAttachmentMap.single, + button_group: basicAttachmentMap.button_group, + buttons: basicAttachmentMap.buttons, + combos: basicAttachmentMap.combos, + editors: basicAttachmentMap.editors, + triggers: basicAttachmentMap.triggers, + calendar: basicAttachmentMap.calendar, + color_chooser: basicAttachmentMap.color_chooser, + segment: basicAttachmentMap.segment, + line_segment: basicAttachmentMap.line_segment, + date: basicAttachmentMap.date, + down_list: basicAttachmentMap.down_list, + text_value_down_list_combo: basicAttachmentMap.text_value_down_list_combo +}; diff --git a/webpack/webpack.prod.js b/webpack/webpack.prod.js index 80eb5ef46..2825d78ff 100644 --- a/webpack/webpack.prod.js +++ b/webpack/webpack.prod.js @@ -10,25 +10,43 @@ const dirs = require("./dirs"); const common = require("./webpack.common.js"); const attachments = require("./attachments"); +const components = require("./components"); module.exports = merge.smart(common, { mode: "production", entry: { font: attachments.font, "fineui.min": attachments.fineui, - 'fineui_without_normalize.min': attachments.fineuiWithoutNormalize, + "fineui_without_normalize.min": attachments.fineuiWithoutNormalize, "fineui.modern.min": attachments.fineuiModern, "fineui.proxy.min": attachments.fineuiProxy, + "core_without_platform": attachments.coreWithoutPlatform, utils: attachments.utils, "utils.min": attachments.utils, "fineui_without_jquery_polyfill": attachments.fineuiWithoutJqueryAndPolyfillJs, "2.0/fineui": attachments.bundle, "2.0/fineui.min": attachments.bundle, "2.0/fineui.modern.min": attachments.bundleModern, - '2.0/fineui_without_normalize': attachments.bundleWithoutNormalize, - '2.0/fineui_without_normalize.min': attachments.bundleWithoutNormalize, + "2.0/fineui_without_normalize": attachments.bundleWithoutNormalize, + "2.0/fineui_without_normalize.min": attachments.bundleWithoutNormalize, + "2.0/core_without_platform": attachments.coreWithoutPlatform, + "2.0/core_without_platform.min": attachments.coreWithoutPlatform, core: attachments.coreJs, resource: attachments.resource, + // 组件库独立组件 + "components/single": components.single, + "components/button_group": components.button_group, + "components/buttons": components.buttons, + "components/combos": components.combos, + "components/editors": components.editors, + "components/triggers": components.triggers, + "components/calendar": components.calendar, + "components/color_chooser": components.color_chooser, + "components/segment": components.segment, + "components/line_segment": components.line_segment, + "components/date": components.date, + "components/down_list": components.down_list, + "components/text_value_down_list_combo": components.text_value_down_list_combo }, optimization: { minimizer: [ @@ -38,27 +56,27 @@ module.exports = merge.smart(common, { sourceMap: true, terserOptions: { output: { - comments: false, - }, - }, + comments: false + } + } }), new webpack.BannerPlugin({ - banner: `time: ${new Date().toLocaleString()}`, - }), - ], + banner: `time: ${new Date().toLocaleString()}` + }) + ] }, devtool: "hidden-source-map", output: { path: dirs.DEST, - filename: "[name].js", + filename: "[name].js" }, plugins: [ new MiniCssExtractPlugin({ path: dirs.DEST, - filename: "[name].css", + filename: "[name].css" }), new ForkTsCheckerWebpackPlugin({}), new OptimizeCssAssetsPlugin({ @@ -67,13 +85,13 @@ module.exports = merge.smart(common, { cssProcessorPluginOptions: { preset: ["default", { discardComments: { - removeAll: true, + removeAll: true }, - normalizeUnicode: false, - }], + normalizeUnicode: false + }] }, - canPrint: true, - }), + canPrint: true + }) ], module: { @@ -84,11 +102,11 @@ module.exports = merge.smart(common, { { loader: "postcss-loader", options: { - plugins: [], - }, - }, - ], - }, - ], - }, + plugins: [] + } + } + ] + } + ] + } });