Browse Source

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

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

5
package.json

@ -23,7 +23,8 @@
"expose-loader": "0.7.5", "expose-loader": "0.7.5",
"express": "4.15.2", "express": "4.15.2",
"fork-ts-checker-webpack-plugin": "1.4.3", "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", "html-webpack-plugin": "3.2.0",
"husky": "^3.1.0", "husky": "^3.1.0",
"karma": "3.1.4", "karma": "3.1.4",
@ -81,4 +82,4 @@
}, },
"author": "fanruan", "author": "fanruan",
"license": "MIT" "license": "MIT"
} }

29
webpack/attachments.js

@ -1,12 +1,4 @@
const grunt = require("grunt"); const { sync, uniq } = require("./utils");
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 fixJs = "./dist/fix/fix.js"; const fixJs = "./dist/fix/fix.js";
const fixProxyJs = './dist/fix/fix.proxy.js'; const fixProxyJs = './dist/fix/fix.proxy.js';
@ -47,11 +39,12 @@ const basicAttachmentMap = {
lodashJs, lodashJs,
"src/core/**/*.js", "src/core/**/*.js",
"src/data/**/*.js", "src/data/**/*.js",
"!src/core/platform/**/*.js", ], [
"!src/core/controller/**/*.js", "src/core/platform/**/*.js",
"src/core/controller/**/*.js",
]), ]),
core_without_normalize: sync( 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"]), resource: sync(["src/less/resource/**/*.less"]),
font: sync(["public/less/font.less"]), font: sync(["public/less/font.less"]),
@ -133,8 +126,9 @@ const bundleWithoutNormalize = [].concat(
"src/less/widget/**/*.less", "src/less/widget/**/*.less",
"src/less/component/**/*.less", "src/less/component/**/*.less",
"public/less/**/*.less", "public/less/**/*.less",
"!public/less/app.less",
// ts的less // ts的less
], [
"public/less/app.less",
]), ]),
); );
@ -189,15 +183,16 @@ const fineuiWithoutJqueryAndPolyfillJs = [].concat(
lodashJs, lodashJs,
"src/core/**/*.js", "src/core/**/*.js",
"src/data/**/*.js", "src/data/**/*.js",
"!src/core/platform/web/**/*.js", ], [
"src/core/platform/web/**/*.js",
]), ]),
basicAttachmentMap.fix, basicAttachmentMap.fix,
sync([ sync([
"src/base/**/*.js", "src/base/**/*.js",
"src/case/**/*.js", "src/case/**/*.js",
], [
"!src/base/single/input/file.js", "src/base/single/input/file.js",
"!src/case/ztree/**/*.js", "src/case/ztree/**/*.js",
]), ]),
basicAttachmentMap.widget, basicAttachmentMap.widget,
sync([fixCompact, workerCompact, "ui/js/**/*.js"]), sync([fixCompact, workerCompact, "ui/js/**/*.js"]),

14
webpack/components.js

@ -1,12 +1,4 @@
const grunt = require("grunt"); const { sync, uniq } = require("./utils");
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 = { const basicAttachmentMap = {
single: sync(["src/base/single/**/*.js"]), single: sync(["src/base/single/**/*.js"]),
@ -24,7 +16,7 @@ const basicAttachmentMap = {
linear_segment: sync(["src/case/linearsegment/**/*.js"]), linear_segment: sync(["src/case/linearsegment/**/*.js"]),
date: sync(["src/widget/date/**/*.js"]), date: sync(["src/widget/date/**/*.js"]),
down_list: sync(["src/widget/downlist/**/*.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 = { module.exports = {
@ -43,5 +35,5 @@ module.exports = {
linear_segment: basicAttachmentMap.linear_segment, linear_segment: basicAttachmentMap.linear_segment,
date: basicAttachmentMap.date, date: basicAttachmentMap.date,
down_list: basicAttachmentMap.down_list, 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: { module: {
rules: [ rules: [
{ {
test: /\.(js|ts)$/, test: /\.(jsx?|tsx?)$/i,
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$/,
include: [ include: [
dirs.DEMO, dirs.NODE_MODULES,
dirs.SRC, dirs.PRIVATE,
dirs.PUBLIC, dirs.PUBLIC,
dirs.MOBILE, dirs.MOBILE,
dirs.DEMO,
dirs.I18N, dirs.I18N,
dirs.UI, dirs.UI,
dirs.FIX, dirs.FIX,
dirs.TYPESCRIPT,
dirs.SRC,
], ],
exclude: /node_modules(\/|\\)core-js/,
use: [ use: [
{ {
loader: 'source-map-loader', loader: 'babel-loader',
options: { options: {
enforce: 'pre', configFile: dirs.BABEL_CONFIG,
}, },
}, },
], ],

Loading…
Cancel
Save