Browse Source

Merge branch 'master' of ssh://cloud.finedevelop.com:7999/~windy/fineui

es6
windy 5 years ago
parent
commit
294f98964c
  1. 7
      .eslintrc
  2. 37
      Gruntfile.js
  3. 34
      babel.config.ie8.js
  4. 34
      babel.config.js
  5. 4
      dist/2.0/fineui.ie.js
  6. 96
      dist/2.0/fineui.ie.min.js
  7. 1
      dist/2.0/fineui.ie.min.js.map
  8. 4
      dist/2.0/fineui.js
  9. 2
      dist/2.0/fineui.min.css
  10. 96
      dist/2.0/fineui.min.js
  11. 1
      dist/2.0/fineui.min.js.map
  12. 4
      dist/bundle.ie.js
  13. 96
      dist/bundle.ie.min.js
  14. 1
      dist/bundle.ie.min.js.map
  15. 4
      dist/bundle.js
  16. 2
      dist/bundle.min.css
  17. 96
      dist/bundle.min.js
  18. 1
      dist/bundle.min.js.map
  19. 4
      dist/core.js
  20. 1
      dist/es5.fineui.js
  21. 1
      dist/es5.fineui.js.map
  22. 4
      dist/fineui.ie.js
  23. 95
      dist/fineui.ie.min.js
  24. 1
      dist/fineui.ie.min.js.map
  25. 4
      dist/fineui.js
  26. 2
      dist/fineui.min.css
  27. 97
      dist/fineui.min.js
  28. 1
      dist/fineui.min.js.map
  29. 1
      dist/ie.fineui.js
  30. 1
      dist/ie.fineui.js.map
  31. 16
      dist/utils.min.js
  32. 1
      dist/utils.min.js.map
  33. 39
      lib/postbuild/postbuild.js
  34. 86
      package.json
  35. 4
      src/core/platform/web/function.js
  36. 3
      tsconfig.json
  37. 13
      types/global.d.ts
  38. 61
      typescript/core/decorator/decorator.ts
  39. 8
      typescript/index.ts
  40. 9
      webpack/dirs.js
  41. 78
      webpack/webpack.common.js
  42. 50
      webpack/webpack.dev.js
  43. 78
      webpack/webpack.prod.js
  44. 4429
      yarn.lock

7
.eslintrc

@ -55,7 +55,7 @@
// 函数 // 函数
"no-dupe-args": "error", "no-dupe-args": "error",
// 禁止在 function 定义中出现重复的参数 // 禁止在 function 定义中出现重复的参数
"space-before-function-paren": "error", "space-before-function-paren": ["error", {"anonymous": "always", "named": "never", "asyncArrow": "always"}],
// 函数括号前必须要有空格 // 函数括号前必须要有空格
// 变量 // 变量
@ -123,10 +123,7 @@
// 逗号 // 逗号
"comma-style": "error", "comma-style": "error",
// 逗号必须放在行末 // 逗号必须放在行末
"comma-dangle": [ "comma-dangle": ["error", "always-multiline"], // 多行对象字面量中要求拖尾逗号,
"error",
"never"
],
// 多行对象字面量中要求不要拖尾逗号 // 多行对象字面量中要求不要拖尾逗号
"comma-spacing": [ "comma-spacing": [
"error", "error",

37
Gruntfile.js

@ -1,13 +1,11 @@
module.exports = function (grunt) { module.exports = function (grunt) {
function sync(patterns) {
const filterPath = function (patterns) { return [...new Set(grunt.file.expand({
return grunt.file.expand({
filter: function (path) { filter: function (path) {
return !new RegExp(/__test__/g).test(path); return !new RegExp(/__test__/g).test(path);
},
}, patterns))];
} }
}, patterns);
};
// Project configuration. // Project configuration.
grunt.initConfig({ grunt.initConfig({
@ -21,7 +19,7 @@ module.exports = function (grunt) {
dest: "dist/polyfill.js" dest: "dist/polyfill.js"
}, },
coreJs: { coreJs: {
src: filterPath([ src: sync([
"src/core/foundation.js", "src/core/foundation.js",
"src/core/lodash.js", "src/core/lodash.js",
// 'src/core/mvc/**/*.js', // 'src/core/mvc/**/*.js',
@ -45,7 +43,7 @@ module.exports = function (grunt) {
// 最基础的控件 // 最基础的控件
baseJs: { baseJs: {
src: filterPath([ src: sync([
"src/third/**/*.js", "src/third/**/*.js",
"src/base/pane.js", "src/base/pane.js",
"src/base/single/single.js", "src/base/single/single.js",
@ -67,14 +65,14 @@ module.exports = function (grunt) {
}, },
// 实现好的一些基础实例 // 实现好的一些基础实例
caseJs: { caseJs: {
src: filterPath([ src: sync([
"src/case/combo/popup.bubble.js", "src/case/combo/popup.bubble.js",
"src/case/**/*.js" "src/case/**/*.js"
]), ]),
dest: "dist/case.js" dest: "dist/case.js"
}, },
widgetJs: { widgetJs: {
src: filterPath([ src: sync([
"src/widget/**/*.js", "src/widget/**/*.js",
"src/component/**/*.js" "src/component/**/*.js"
]), ]),
@ -109,7 +107,7 @@ module.exports = function (grunt) {
bundleJs: { bundleJs: {
src: ["dist/core.js", "dist/fix/fix.js", "dist/base.js", "dist/case.js", "dist/widget.js", "dist/fix/fix.compact.js", "dist/router.js", "public/js/**/*.js", "public/js/index.js", "i18n/i18n.cn.js"], src: ["dist/core.js", "dist/fix/fix.js", "dist/base.js", "dist/case.js", "dist/widget.js", "dist/fix/fix.compact.js", "dist/router.js", "public/js/**/*.js", "public/js/index.js", "i18n/i18n.cn.js"],
dest: "dist/bundle.js" dest: "dist/bundle.js",
}, },
versionFineuiJs: { versionFineuiJs: {
@ -128,7 +126,7 @@ module.exports = function (grunt) {
}, },
bundleCss: { bundleCss: {
src: ["dist/core.css", "dist/base.css", "dist/widget.css", "public/css/app.css", "public/css/**/*.css"], src: ["dist/core.css", "dist/base.css", "dist/widget.css", "public/css/app.css", "public/css/**/*.css", "fineui.typescript.css"],
dest: "dist/bundle.css" dest: "dist/bundle.css"
}, },
@ -150,7 +148,7 @@ module.exports = function (grunt) {
}, },
fineuiWithoutJqueryAndPolyfillJs: { fineuiWithoutJqueryAndPolyfillJs: {
src: filterPath(["src/core/foundation.js", src: sync(["src/core/foundation.js",
"src/core/lodash.js", "src/core/lodash.js",
// 'src/core/mvc/**/*.js', // 'src/core/mvc/**/*.js',
"src/core/base.js", "src/core/base.js",
@ -193,7 +191,7 @@ module.exports = function (grunt) {
}, },
fineuiCss: { fineuiCss: {
src: ["dist/core.css", "dist/base.css", "dist/widget.css", "ui/css/app.css", "ui/css/**/*.css"], src: ["dist/core.css", "dist/base.css", "dist/widget.css", "ui/css/app.css", "ui/css/**/*.css", "fineui.typescript.css"],
dest: "dist/fineui.css" dest: "dist/fineui.css"
}, },
@ -234,7 +232,6 @@ module.exports = function (grunt) {
} }
}, },
less: { less: {
demo: { demo: {
expand: true, expand: true,
@ -274,7 +271,13 @@ module.exports = function (grunt) {
uglify: { uglify: {
options: { options: {
banner: "/*! <%= pkg.name %> <%= grunt.template.today(\"yyyy-mm-dd HH:MM:ss\") %> */\n" banner: "/*! <%= pkg.name %> <%= grunt.template.today(\"yyyy-mm-dd HH:MM:ss\") %> */\n",
mangle: false,
sourceMap: true,
sourceMapIncludeSources: true,
compress: {
unused: false,
},
}, },
dist: { dist: {
files: { files: {
@ -423,7 +426,7 @@ module.exports = function (grunt) {
grunt.file.write(dest, JSON.stringify(stat)); grunt.file.write(dest, JSON.stringify(stat));
}); });
var defaultTask = ["clean", "less", "concat", "connect", "watch"]; var defaultTask = ["clean", "less", "concat", "watch"];
grunt.registerTask("default", defaultTask); grunt.registerTask("default", defaultTask);
grunt.registerTask("compile", function () { grunt.registerTask("compile", function () {
grunt.config.set("connect.options.open", false); grunt.config.set("connect.options.open", false);

34
babel.config.ie8.js

@ -0,0 +1,34 @@
module.exports = function (api) {
api.cache(true);
const presets = [
[
"@babel/preset-env",
{
targets: {
ie: 8,
},
},
],
"@babel/preset-typescript",
];
const plugins = [
[
"@babel/plugin-proposal-decorators",
{
legacy: true,
},
],
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-block-scoping",
["@babel/plugin-transform-classes", {
loose: true,
}],
"@babel/plugin-transform-proto-to-assign",
"@babel/plugin-transform-modules-commonjs",
];
return {
presets,
plugins,
};
};

34
babel.config.js

@ -0,0 +1,34 @@
module.exports = function (api) {
api.cache(true);
const presets = [
[
"@babel/preset-env",
{
targets: {
ie: 9,
chrome: 47,
},
},
],
"@babel/preset-typescript",
];
const plugins = [
[
"@babel/plugin-proposal-decorators",
{
legacy: true,
},
],
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-block-scoping",
["@babel/plugin-transform-classes", {
loose: true,
}],
"@babel/plugin-transform-proto-to-assign",
];
return {
presets,
plugins,
};
};

4
dist/2.0/fineui.ie.js vendored

@ -22727,6 +22727,10 @@ _.extend(BI, {
humpString = [], humpString = [],
htmlStyle = document.documentElement.style, htmlStyle = document.documentElement.style,
_toHumb = function (string) { _toHumb = function (string) {
if (!BI.isString(string)) {
return "";
}
return string.replace(/-(\w)/g, function ($0, $1) { return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase(); return $1.toUpperCase();
}); });

96
dist/2.0/fineui.ie.min.js vendored

File diff suppressed because one or more lines are too long

1
dist/2.0/fineui.ie.min.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/2.0/fineui.js vendored

@ -22727,6 +22727,10 @@ _.extend(BI, {
humpString = [], humpString = [],
htmlStyle = document.documentElement.style, htmlStyle = document.documentElement.style,
_toHumb = function (string) { _toHumb = function (string) {
if (!BI.isString(string)) {
return "";
}
return string.replace(/-(\w)/g, function ($0, $1) { return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase(); return $1.toUpperCase();
}); });

2
dist/2.0/fineui.min.css vendored

File diff suppressed because one or more lines are too long

96
dist/2.0/fineui.min.js vendored

File diff suppressed because one or more lines are too long

1
dist/2.0/fineui.min.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/bundle.ie.js vendored

@ -22727,6 +22727,10 @@ _.extend(BI, {
humpString = [], humpString = [],
htmlStyle = document.documentElement.style, htmlStyle = document.documentElement.style,
_toHumb = function (string) { _toHumb = function (string) {
if (!BI.isString(string)) {
return "";
}
return string.replace(/-(\w)/g, function ($0, $1) { return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase(); return $1.toUpperCase();
}); });

96
dist/bundle.ie.min.js vendored

File diff suppressed because one or more lines are too long

1
dist/bundle.ie.min.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/bundle.js vendored

@ -22727,6 +22727,10 @@ _.extend(BI, {
humpString = [], humpString = [],
htmlStyle = document.documentElement.style, htmlStyle = document.documentElement.style,
_toHumb = function (string) { _toHumb = function (string) {
if (!BI.isString(string)) {
return "";
}
return string.replace(/-(\w)/g, function ($0, $1) { return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase(); return $1.toUpperCase();
}); });

2
dist/bundle.min.css vendored

File diff suppressed because one or more lines are too long

96
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

1
dist/bundle.min.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/core.js vendored

@ -22727,6 +22727,10 @@ _.extend(BI, {
humpString = [], humpString = [],
htmlStyle = document.documentElement.style, htmlStyle = document.documentElement.style,
_toHumb = function (string) { _toHumb = function (string) {
if (!BI.isString(string)) {
return "";
}
return string.replace(/-(\w)/g, function ($0, $1) { return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase(); return $1.toUpperCase();
}); });

1
dist/es5.fineui.js vendored

File diff suppressed because one or more lines are too long

1
dist/es5.fineui.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/fineui.ie.js vendored

@ -22972,6 +22972,10 @@ _.extend(BI, {
humpString = [], humpString = [],
htmlStyle = document.documentElement.style, htmlStyle = document.documentElement.style,
_toHumb = function (string) { _toHumb = function (string) {
if (!BI.isString(string)) {
return "";
}
return string.replace(/-(\w)/g, function ($0, $1) { return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase(); return $1.toUpperCase();
}); });

95
dist/fineui.ie.min.js vendored

File diff suppressed because one or more lines are too long

1
dist/fineui.ie.min.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/fineui.js vendored

@ -22972,6 +22972,10 @@ _.extend(BI, {
humpString = [], humpString = [],
htmlStyle = document.documentElement.style, htmlStyle = document.documentElement.style,
_toHumb = function (string) { _toHumb = function (string) {
if (!BI.isString(string)) {
return "";
}
return string.replace(/-(\w)/g, function ($0, $1) { return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase(); return $1.toUpperCase();
}); });

2
dist/fineui.min.css vendored

File diff suppressed because one or more lines are too long

97
dist/fineui.min.js vendored

File diff suppressed because one or more lines are too long

1
dist/fineui.min.js.map vendored

File diff suppressed because one or more lines are too long

1
dist/ie.fineui.js vendored

File diff suppressed because one or more lines are too long

1
dist/ie.fineui.js.map vendored

File diff suppressed because one or more lines are too long

16
dist/utils.min.js vendored

File diff suppressed because one or more lines are too long

1
dist/utils.min.js.map vendored

File diff suppressed because one or more lines are too long

39
lib/postbuild/postbuild.js

@ -0,0 +1,39 @@
const Concat = require("concat-with-sourcemaps");
const { resolve } = require("path");
const fs = require("fs");
function unionJs(filenames) {
const filename = filenames[0];
var concat = new Concat(true, filename, "\n");
filenames.forEach(filename => {
concat.add(
filename,
fs.readFileSync(resolve(__dirname, `../../dist/${filename}`)),
fs.readFileSync(resolve(__dirname, `../../dist/${filename}.map`)).toString()
);
});
const filenameParts = filename.split("/");
concat.add(null, `//# sourceMappingURL=${filenameParts[filenameParts.length - 1]}.map`);
var concatenatedContent = concat.content;
var sourceMapForContent = concat.sourceMap;
fs.writeFileSync(resolve(__dirname, "../../dist", filename), concatenatedContent, {
encoding: "utf8",
});
fs.writeFileSync(resolve(__dirname, "../../dist", `${filename}.map`), sourceMapForContent, {
encoding: "utf8",
});
}
unionJs(["bundle.min.js", "es5.fineui.js"]);
unionJs(["bundle.ie.min.js", "ie.fineui.js"]);
unionJs(["fineui.min.js", "es5.fineui.js"]);
unionJs(["fineui.ie.min.js", "ie.fineui.js"]);
unionJs(["2.0/fineui.min.js", "es5.fineui.js"]);
unionJs(["2.0/fineui.ie.min.js", "ie.fineui.js"]);

86
package.json

@ -5,38 +5,76 @@
"main": "typescript/index.ts", "main": "typescript/index.ts",
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^1.11.0", "@babel/core": "7.4.5",
"@typescript-eslint/parser": "^1.11.0", "@babel/plugin-proposal-class-properties": "7.5.0",
"chai": "^4.2.0", "@babel/plugin-proposal-decorators": "7.4.4",
"eslint": "^6.0.1", "@babel/plugin-transform-block-scoping": "7.5.5",
"express": "^4.15.2", "@babel/plugin-transform-classes": "7.5.5",
"grunt": "^1.0.1", "@babel/plugin-transform-modules-commonjs": "7.6.0",
"grunt-contrib-clean": "^1.1.0", "@babel/plugin-transform-proto-to-assign": "7.5.5",
"grunt-contrib-concat": "^1.0.1", "@babel/polyfill": "7.6.0",
"grunt-contrib-connect": "^1.0.2", "@babel/preset-env": "7.4.5",
"grunt-contrib-copy": "^1.0.0", "@babel/preset-typescript": "7.3.3",
"grunt-contrib-cssmin": "^1.0.1", "@typescript-eslint/eslint-plugin": "1.11.0",
"grunt-contrib-jshint": "^1.0.0", "@typescript-eslint/parser": "1.11.0",
"grunt-contrib-less": "^1.4.1", "autoprefixer": "9.6.1",
"grunt-contrib-uglify": "^1.0.1", "babel-loader": "8.0.6",
"grunt-contrib-watch": "^1.0.0", "chai": "4.2.0",
"karma": "^3.1.4", "concat-with-sourcemaps": "1.1.0",
"karma-chai": "^0.1.0", "core-js": "3.3.2",
"karma-chrome-launcher": "^2.2.0", "cross-env": "6.0.0",
"karma-coverage": "^1.1.2", "css-loader": "3.0.0",
"karma-mocha": "^1.3.0", "es6-promise": "4.2.8",
"mocha": "^5.2.0", "eslint": "6.0.1",
"express": "4.15.2",
"fork-ts-checker-webpack-plugin": "1.4.3",
"grunt": "1.0.1",
"grunt-contrib-clean": "1.1.0",
"grunt-contrib-concat": "1.0.1",
"grunt-contrib-connect": "1.0.2",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-cssmin": "1.0.1",
"grunt-contrib-jshint": "1.0.0",
"grunt-contrib-less": "1.4.1",
"grunt-contrib-uglify": "1.0.1",
"grunt-contrib-watch": "1.0.0",
"grunt-webpack": "3.1.3",
"html-webpack-plugin": "3.2.0",
"karma": "3.1.4",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "1.1.2",
"karma-mocha": "1.3.0",
"less-loader": "5.0.0",
"mini-css-extract-plugin": "0.7.0",
"mocha": "5.2.0",
"npm-run-all": "4.1.5",
"open": "0.0.5", "open": "0.0.5",
"typescript": "^3.5.2" "optimize-css-assets-webpack-plugin": "5.0.3",
"postcss-loader": "3.0.0",
"postcss-simple-vars": "5.0.2",
"source-map-loader": "0.2.4",
"style-loader": "0.23.1",
"typescript": "3.5.2",
"uglifyjs-webpack-plugin": "2.2.0",
"webpack": "4.35.2",
"webpack-cli": "3.3.5",
"webpack-dev-server": "3.7.2",
"webpack-merge": "4.2.1"
}, },
"scripts": { "scripts": {
"grunt": "grunt", "grunt": "grunt",
"webpack:dev": "webpack-dev-server -p --progress --config=webpack/webpack.dev.js --mode development",
"webpack:prod": "webpack -p --progress --config=webpack/webpack.prod.js --mode production",
"webpack:prod:ie8": "cross-env BROWSER_VERSION=ie8 webpack -p --progress --config=webpack/webpack.prod.js --mode production",
"start": "node server.js", "start": "node server.js",
"build": "grunt build", "build": "npm run webpack:prod && npm run webpack:prod:ie8 && grunt build",
"postbuild": "node ./lib/postbuild/postbuild.js",
"compile": "grunt compile", "compile": "grunt compile",
"fake": "grunt fake-build", "fake": "grunt fake-build",
"test": "karma start", "test": "karma start",
"analyze": "grunt analyze" "analyze": "grunt analyze",
"dev": "npm-run-all --parallel grunt webpack:dev"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

4
src/core/platform/web/function.js

@ -105,6 +105,10 @@ _.extend(BI, {
humpString = [], humpString = [],
htmlStyle = document.documentElement.style, htmlStyle = document.documentElement.style,
_toHumb = function (string) { _toHumb = function (string) {
if (!BI.isString(string)) {
return "";
}
return string.replace(/-(\w)/g, function ($0, $1) { return string.replace(/-(\w)/g, function ($0, $1) {
return $1.toUpperCase(); return $1.toUpperCase();
}); });

3
tsconfig.json

@ -22,6 +22,7 @@
}, },
"include": [ "include": [
"typescript/*.ts", "typescript/*.ts",
"typescript/**/*.ts" "typescript/**/*.ts",
"types/*.d.ts"
] ]
} }

13
types/global.d.ts vendored

@ -0,0 +1,13 @@
interface Obj {
[key: string]: any;
}
declare let BI: Obj & import("../typescript/index")._BI;
// declare let BI: Obj;
declare const Fix: Obj;
declare interface String {
replaceAll(regx: string, callback: (str: string) => void): string;
}

61
typescript/core/decorator/decorator.ts

@ -0,0 +1,61 @@
export type Constructor<T> = new(...args: any[]) => T;
/**
* widget
*/
export function shortcut() {
return function decorator<U>(Target: Constructor<U> & {xtype: string}): void {
BI.shortcut(Target.xtype, Target);
};
}
/**
* model
*/
export function model() {
return function decorator<U extends {new(...args:any[]):{}} & {xtype: string, context?: ReadonlyArray<string>}>(Target: U): void {
BI.model(Target.xtype, Target);
};
}
/**
* _store属性
* @param Model model类
* @param opts
*/
export function store<T>(Model: Constructor<T> & {xtype: string}, opts: { props?(this: unknown): { [key: string]: unknown } } = {}) {
return function classDecorator<U extends {new(...args:any[]):{}}>(constructor:U) {
return class extends constructor {
_store() {
const props = opts.props ? opts.props.apply(this) : undefined;
return BI.Models.getModel(Model.xtype, props);
}
};
};
}
/**
* Model基类
*/
export class Model<U extends {types?: {[key: string]: unknown} | {}, context?: ReadonlyArray<string>} = {}> extends Fix.Model {
// @ts-ignore this["computed"][key]为空
model: Pick<{[key in keyof U["types"]]: U["types"][key]}, U["context"][number]> & {[key in keyof ReturnType<this["state"]>]: ReturnType<this["state"]>[key]} & {[key in keyof this["computed"]]: ReturnType<this["computed"][key]>};
store: this["actions"];
state(): {[key: string]: unknown} | {} {
return {};
}
context: U["context"];
actions:{[key: string]: (...args: any[]) => any};
childContext: ReadonlyArray<keyof (this["computed"] & ReturnType<this["state"]>)>;
// @ts-ignore this["computed"][key]为空
TYPE: Pick<{[key in keyof this["computed"]]: ReturnType<this["computed"][key]>} & {[key in keyof ReturnType<this["state"]>]: ReturnType<this["state"]>[key]}, this["childContext"][number]>;
computed: {[key: string]: () => unknown} | {};
}

8
typescript/index.ts

@ -1,3 +1,5 @@
import * as decorator from "./core/decorator/decorator";
import { _i18n } from "./core/i18n"; import { _i18n } from "./core/i18n";
import { _OB } from "./core/ob"; import { _OB } from "./core/ob";
import { _func } from "./core/func"; import { _func } from "./core/func";
@ -14,7 +16,6 @@ import { _RedMarkBehavior } from "./core/behavior/behavior.redmark";
import { _Pane, _PaneStatic } from "./base/pane"; import { _Pane, _PaneStatic } from "./base/pane";
import { _LoadingPane } from "./case/loading/loading_pane"; import { _LoadingPane } from "./case/loading/loading_pane";
type ClassConstructor<T extends {}> = T & { type ClassConstructor<T extends {}> = T & {
new(config: any): T; new(config: any): T;
(config: any): T; (config: any): T;
@ -36,4 +37,9 @@ export interface _BI extends _func, _i18n, _base {
RedMarkBehavior: ClassConstructor<_RedMarkBehavior>; RedMarkBehavior: ClassConstructor<_RedMarkBehavior>;
Pane: ClassConstructor<_Pane> & _PaneStatic; Pane: ClassConstructor<_Pane> & _PaneStatic;
LoadingPane: ClassConstructor<_LoadingPane>; LoadingPane: ClassConstructor<_LoadingPane>;
Decorators: typeof decorator;
} }
BI = BI.extend(BI, {
Decorators: decorator,
}) as any;

9
webpack/dirs.js

@ -0,0 +1,9 @@
const path = require("path");
module.exports = {
DEST: path.resolve(__dirname, "../dist"),
NODE_MODULES: path.resolve(__dirname, "../node_modules"),
PRIVATE: path.resolve(__dirname, "../private"),
BABEL_CONFIG: path.resolve(__dirname, "../babel.config.js"),
IE8_BABEL_CONFIG: path.resolve(__dirname, "../babel.config.ie8.js"),
TYPESCRIPT: path.resolve(__dirname, "../typescript"),
};

78
webpack/webpack.common.js

@ -0,0 +1,78 @@
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const autoprefixer = require("autoprefixer");
const dirs = require("./dirs");
const isBuilt4IE8 = process.env.BROWSER_VERSION === "ie8";
module.exports = {
entry: {
fineui: [
...isBuilt4IE8
? [
"core-js/features/object/define-property",
"core-js/features/object/create",
"core-js/features/object/assign",
"core-js/features/array/for-each",
"core-js/features/array/index-of",
"core-js/features/function/bind",
"core-js/features/promise",
"core-js/features/object/get-own-property-symbols",
"core-js/features/string/replace",
// "core-js",
]
: [
"@babel/polyfill",
"es6-promise/auto",
],
"./typescript/index.ts",
],
},
resolve: {
mainFields: ["module", "main"],
extensions: [".js", ".ts"],
},
module: {
rules: [
{
test: /\.(js|ts)$/,
include: [dirs.NODE_MODULES, dirs.PRIVATE, dirs.TYPESCRIPT],
use: [{
loader: "babel-loader",
options: {
configFile: isBuilt4IE8 ? dirs.IE8_BABEL_CONFIG : dirs.BABEL_CONFIG,
},
}, {
loader: "source-map-loader",
options: {
enforce: "pre",
},
}],
},
{
test: /\.(css|less)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
url: false,
},
},
{
loader: "postcss-loader",
options: {
plugins: [autoprefixer],
},
},
{
loader: "less-loader",
options: {
relativeUrls: false,
},
},
],
},
],
},
};

50
webpack/webpack.dev.js

@ -0,0 +1,50 @@
const merge = require("webpack-merge");
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
const OptimizeCssAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const dirs = require("./dirs");
const common = require("./webpack.common.js");
module.exports = merge(common, {
devtool: "eval-source-map",
output: {
path: dirs.DEST,
filename: "[name].[contenthash].js",
},
devServer: {
contentBase: path.join(__dirname, ".."),
port: 9001,
liveReload: true,
},
plugins: [
new MiniCssExtractPlugin({
path: dirs.DEST,
filename: "fineui.[contenthash].css",
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "../index.html"),
chunks: ["fineui"],
chunksSortMode: "manual",
}),
new ForkTsCheckerWebpackPlugin({
watch: ["./typescript"],
}),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/g,
cssProcessor: require("cssnano"),
cssProcessorPluginOptions: {
preset: ["default", {
discardComments: {
removeAll: true,
},
normalizeUnicode: false,
}],
},
canPrint: true,
}),
],
});

78
webpack/webpack.prod.js

@ -0,0 +1,78 @@
const webpack = require("webpack");
const merge = require("webpack-merge");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
const OptimizeCssAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const isBuilt4IE8 = process.env.BROWSER_VERSION === "ie8";
const dirs = require("./dirs");
const common = require("./webpack.common.js");
module.exports = merge.smart(common, {
mode: "production",
optimization: {
minimizer: [
new UglifyJsPlugin({
parallel: true,
sourceMap: true,
uglifyOptions: {
ie8: true,
output: {
comments: false,
},
}
})
]
},
devtool: "hidden-source-map",
output: {
path: dirs.DEST,
filename: isBuilt4IE8 ? "ie.fineui.js" : "es5.fineui.js",
},
plugins: [
new MiniCssExtractPlugin({
path: dirs.DEST,
filename: "es5.fineui.css",
}),
new webpack.BannerPlugin({
banner: `time: ${new Date().toLocaleString()}`,
}),
new ForkTsCheckerWebpackPlugin({
}),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/g,
cssProcessor: require("cssnano"),
cssProcessorPluginOptions: {
preset: ["default", {
discardComments: {
removeAll: true,
},
normalizeUnicode: false,
}],
},
canPrint: true,
}),
],
module: {
rules: [
{
test: /\.(css|less)$/,
use: [
{
loader: "postcss-loader",
options: {
plugins: [],
},
},
],
},
],
},
});

4429
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save