From a48a5cb0c065a7baa8dd23495be75ed8f7b4742b Mon Sep 17 00:00:00 2001 From: zsmj Date: Sun, 13 Mar 2022 16:59:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=20chore:=20=E6=94=B9=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E6=89=93=E5=8C=85.=20and=20babel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 5 +++-- webpack/attachments.js | 29 ++++++++++++----------------- webpack/components.js | 14 +++----------- webpack/utils.js | 24 ++++++++++++++++++++++++ webpack/webpack.common.js | 33 +++++++++------------------------ 5 files changed, 51 insertions(+), 54 deletions(-) create mode 100644 webpack/utils.js diff --git a/package.json b/package.json index 618aafde5..dff5e1f39 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "expose-loader": "0.7.5", "express": "4.15.2", "fork-ts-checker-webpack-plugin": "1.4.3", - "grunt": "1.0.1", + "glob": "^7.2.0", + "grunt": "^1.0.1", "html-webpack-plugin": "3.2.0", "husky": "^3.1.0", "karma": "3.1.4", @@ -81,4 +82,4 @@ }, "author": "fanruan", "license": "MIT" -} \ No newline at end of file +} diff --git a/webpack/attachments.js b/webpack/attachments.js index 3b92c2714..eefbe4b42 100644 --- a/webpack/attachments.js +++ b/webpack/attachments.js @@ -1,12 +1,4 @@ -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 { sync, uniq } = require("./utils"); const fixJs = "./dist/fix/fix.js"; const fixProxyJs = './dist/fix/fix.proxy.js'; @@ -47,11 +39,12 @@ const basicAttachmentMap = { lodashJs, "src/core/**/*.js", "src/data/**/*.js", - "!src/core/platform/**/*.js", - "!src/core/controller/**/*.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"], + ["src/less/core/**/*.less", "src/less/theme/**/*.less"], ["src/less/core/normalize.less", "src/less/core/normalize2.less"] ), resource: sync(["src/less/resource/**/*.less"]), font: sync(["public/less/font.less"]), @@ -133,8 +126,9 @@ const bundleWithoutNormalize = [].concat( "src/less/widget/**/*.less", "src/less/component/**/*.less", "public/less/**/*.less", - "!public/less/app.less", // tsēš„less + ], [ + "public/less/app.less", ]), ); @@ -189,15 +183,16 @@ const fineuiWithoutJqueryAndPolyfillJs = [].concat( lodashJs, "src/core/**/*.js", "src/data/**/*.js", - "!src/core/platform/web/**/*.js", + ], [ + "src/core/platform/web/**/*.js", ]), basicAttachmentMap.fix, sync([ "src/base/**/*.js", "src/case/**/*.js", - - "!src/base/single/input/file.js", - "!src/case/ztree/**/*.js", + ], [ + "src/base/single/input/file.js", + "src/case/ztree/**/*.js", ]), basicAttachmentMap.widget, sync([fixCompact, workerCompact, "ui/js/**/*.js"]), diff --git a/webpack/components.js b/webpack/components.js index cb69f6333..0162cfd2a 100644 --- a/webpack/components.js +++ b/webpack/components.js @@ -1,12 +1,4 @@ -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 { sync, uniq } = require("./utils"); const basicAttachmentMap = { single: sync(["src/base/single/**/*.js"]), @@ -24,7 +16,7 @@ const basicAttachmentMap = { 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"]) + text_value_down_list_combo: sync(["src/widget/textvaluedownlistcombo/**/*.js"]), }; module.exports = { @@ -43,5 +35,5 @@ module.exports = { linear_segment: basicAttachmentMap.linear_segment, date: basicAttachmentMap.date, down_list: basicAttachmentMap.down_list, - text_value_down_list_combo: basicAttachmentMap.text_value_down_list_combo + text_value_down_list_combo: basicAttachmentMap.text_value_down_list_combo, }; diff --git a/webpack/utils.js b/webpack/utils.js new file mode 100644 index 000000000..7ed3de515 --- /dev/null +++ b/webpack/utils.js @@ -0,0 +1,24 @@ +const path = require('path'); +const glob = require('glob'); + +// const glob = require('fast-glob'); + +function uniq(names) { + return [...new Set(names)]; +} + +const globalExcludes = [ + "**/*/__test__/*.js", +]; + +function sync(patterns, excludes = []) { + const ignore = globalExcludes.concat(excludes).map(pattern => path.join(__dirname, "../", pattern).replace(/\\/g, '/')); + + return patterns.map(pattern => glob.sync(path.join(__dirname, "../", pattern).replace(/\\/g, '/'), { ignore })).flat(); +} + + +module.exports = { + sync, + uniq, +}; diff --git a/webpack/webpack.common.js b/webpack/webpack.common.js index a75912f83..e19801a99 100644 --- a/webpack/webpack.common.js +++ b/webpack/webpack.common.js @@ -37,40 +37,25 @@ module.exports = { module: { rules: [ { - test: /\.(js|ts)$/, - include: [dirs.NODE_MODULES, dirs.PRIVATE, dirs.TYPESCRIPT, dirs.ROUTER], - exclude: /node_modules(\/|\\)core-js/, - use: [ - { - loader: 'babel-loader', - options: { - configFile: dirs.BABEL_CONFIG, - }, - }, - { - loader: 'source-map-loader', - options: { - enforce: 'pre', - }, - }, - ], - }, - { - test: /\.js$/, + test: /\.(jsx?|tsx?)$/i, include: [ - dirs.DEMO, - dirs.SRC, + dirs.NODE_MODULES, + dirs.PRIVATE, dirs.PUBLIC, dirs.MOBILE, + dirs.DEMO, dirs.I18N, dirs.UI, dirs.FIX, + dirs.TYPESCRIPT, + dirs.SRC, ], + exclude: /node_modules(\/|\\)core-js/, use: [ { - loader: 'source-map-loader', + loader: 'babel-loader', options: { - enforce: 'pre', + configFile: dirs.BABEL_CONFIG, }, }, ],