Browse Source

无JIRA chore: 改一下打包. and babel

es6
zsmj 3 years ago
parent
commit
a48a5cb0c0
  1. 3
      package.json
  2. 29
      webpack/attachments.js
  3. 14
      webpack/components.js
  4. 24
      webpack/utils.js
  5. 33
      webpack/webpack.common.js

3
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",

29
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"]),

14
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,
};

24
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,
};

33
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,
},
},
],

Loading…
Cancel
Save