Browse Source

chore: ie8版本兼容不报错

master
iapyang 5 years ago
parent
commit
309cca4206
  1. 12
      Gruntfile.js
  2. 34
      babel.config.ie8.js
  3. 10
      package.json
  4. 1
      webpack/dirs.js
  5. 12
      webpack/webpack.common.js
  6. 7
      webpack/webpack.prod.js
  7. 39
      yarn.lock

12
Gruntfile.js

@ -106,7 +106,7 @@ module.exports = function (grunt) {
},
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", "dist/fineui.typescript.js"],
dest: "dist/bundle.js"
},
@ -116,7 +116,7 @@ module.exports = function (grunt) {
},
bundleIEJs: {
src: ["dist/core.js", "dist/fix/fix.ie.js", "dist/base.js", "dist/case.js", "dist/widget.js", "dist/fix/fix.compact.ie.js", "dist/router.js", "public/js/**/*.js", "public/js/index.js", "i18n/i18n.cn.js"],
src: ["dist/core.js", "dist/fix/fix.ie.js", "dist/base.js", "dist/case.js", "dist/widget.js", "dist/fix/fix.compact.ie.js", "dist/router.js", "public/js/**/*.js", "public/js/index.js", "i18n/i18n.cn.js", "dist/fineui.typescript.ie8.js"],
dest: "dist/bundle.ie.js"
},
@ -126,7 +126,7 @@ module.exports = function (grunt) {
},
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"
},
@ -137,13 +137,13 @@ module.exports = function (grunt) {
fineuiJs: {
src: ["dist/polyfill.js", "dist/core.js", "dist/fix/fix.js", "dist/base.js",
"dist/case.js", "dist/widget.js", "dist/router.js", "dist/fix/fix.compact.js", "ui/js/**/*.js"],
"dist/case.js", "dist/widget.js", "dist/router.js", "dist/fix/fix.compact.js", "ui/js/**/*.js", "dist/fineui.typescript.js"],
dest: "dist/fineui.js"
},
fineuiIEJs: {
src: ["dist/polyfill.js", "dist/core.js", "dist/fix/fix.ie.js", "dist/base.js",
"dist/case.js", "dist/widget.js", "dist/router.js", "dist/fix/fix.compact.ie.js", "ui/js/**/*.js"],
"dist/case.js", "dist/widget.js", "dist/router.js", "dist/fix/fix.compact.ie.js", "ui/js/**/*.js", "dist/fineui.typescript.ie.js"],
dest: "dist/fineui.ie.js"
},
@ -191,7 +191,7 @@ module.exports = function (grunt) {
},
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"
},

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

10
package.json

@ -10,9 +10,9 @@
"@babel/plugin-proposal-decorators": "7.4.4",
"@babel/plugin-transform-block-scoping": "7.5.5",
"@babel/plugin-transform-classes": "7.5.5",
"@babel/plugin-transform-modules-commonjs": "7.5.0",
"@babel/plugin-transform-modules-commonjs": "7.6.0",
"@babel/plugin-transform-proto-to-assign": "7.5.5",
"@babel/polyfill": "7.4.4",
"@babel/polyfill": "7.6.0",
"@babel/preset-env": "7.4.5",
"@babel/preset-typescript": "7.3.3",
"@typescript-eslint/eslint-plugin": "1.11.0",
@ -20,6 +20,8 @@
"autoprefixer": "9.6.1",
"babel-loader": "8.0.6",
"chai": "4.2.0",
"core-js": "3.3.2",
"cross-env": "6.0.0",
"css-loader": "3.0.0",
"es6-promise": "4.2.8",
"eslint": "6.0.1",
@ -62,8 +64,10 @@
"scripts": {
"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",
"build": "grunt build",
"build": "npm run webpack:prod && npm run webpack:prod:ie8 && grunt build",
"compile": "grunt compile",
"fake": "grunt fake-build",
"test": "karma start",

1
webpack/dirs.js

@ -4,5 +4,6 @@ module.exports = {
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"),
};

12
webpack/webpack.common.js

@ -3,9 +3,19 @@ const autoprefixer = require("autoprefixer");
const dirs = require("./dirs");
const isBuilt4IE8 = process.env.BROWSER_VERSION === "ie8";
module.exports = {
entry: {
fineui: [
...isBuilt4IE8
? [
"core-js",
]
: [
"@babel/polyfill",
"es6-promise/auto",
],
"./typescript/index.ts",
],
},
@ -21,7 +31,7 @@ module.exports = {
use: [{
loader: "babel-loader",
options: {
configFile: dirs.BABEL_CONFIG,
configFile: isBuilt4IE8 ? dirs.IE8_BABEL_CONFIG : dirs.BABEL_CONFIG,
},
}, {
loader: "source-map-loader",

7
webpack/webpack.prod.js

@ -5,6 +5,8 @@ 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");
@ -16,19 +18,20 @@ module.exports = merge.smart(common, {
output: {
path: dirs.DEST,
filename: "webpack",
filename: isBuilt4IE8 ? "fineui.typescript.ie.js" : "fineui.typescript.js",
},
plugins: [
new MiniCssExtractPlugin({
path: dirs.DEST,
filename: "plugin.jsondata.es5.css",
filename: "fineui.typescript.css",
}),
new UglifyJsPlugin({
test: /\.js(\?.*)?$/i,
parallel: 16,
sourceMap: true,
uglifyOptions: {
ie8: true,
output: {
comments: false,
},

39
yarn.lock

@ -410,16 +410,7 @@
"@babel/helper-plugin-utils" "^7.0.0"
babel-plugin-dynamic-import-node "^2.3.0"
"@babel/plugin-transform-modules-commonjs@7.5.0":
version "7.5.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.5.0.tgz#425127e6045231360858eeaa47a71d75eded7a74"
dependencies:
"@babel/helper-module-transforms" "^7.4.4"
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/helper-simple-access" "^7.1.0"
babel-plugin-dynamic-import-node "^2.3.0"
"@babel/plugin-transform-modules-commonjs@^7.4.4":
"@babel/plugin-transform-modules-commonjs@7.6.0", "@babel/plugin-transform-modules-commonjs@^7.4.4":
version "7.6.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.6.0.tgz#39dfe957de4420445f1fcf88b68a2e4aa4515486"
dependencies:
@ -543,9 +534,9 @@
"@babel/helper-regex" "^7.4.4"
regexpu-core "^4.6.0"
"@babel/polyfill@7.4.4":
version "7.4.4"
resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.4.4.tgz#78801cf3dbe657844eeabf31c1cae3828051e893"
"@babel/polyfill@7.6.0":
version "7.6.0"
resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.6.0.tgz#6d89203f8b6cd323e8d946e47774ea35dc0619cc"
dependencies:
core-js "^2.6.5"
regenerator-runtime "^0.13.2"
@ -1946,6 +1937,10 @@ core-js-compat@^3.1.1:
browserslist "^4.6.6"
semver "^6.3.0"
core-js@3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.3.2.tgz#cd42da1d7b0bb33ef11326be3a721934277ceb42"
core-js@^2.2.0, core-js@^2.6.5:
version "2.6.9"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2"
@ -1991,6 +1986,12 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
safe-buffer "^5.0.1"
sha.js "^2.4.8"
cross-env@6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-6.0.0.tgz#3c8e71440ea20aa6faaf5aec541235efc565dac6"
dependencies:
cross-spawn "^7.0.0"
cross-spawn@6.0.5, cross-spawn@^6.0.0, cross-spawn@^6.0.5:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
@ -2001,6 +2002,14 @@ cross-spawn@6.0.5, cross-spawn@^6.0.0, cross-spawn@^6.0.5:
shebang-command "^1.2.0"
which "^1.2.9"
cross-spawn@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.0.tgz#21ef9470443262f33dba80b2705a91db959b2e03"
dependencies:
path-key "^3.1.0"
shebang-command "^1.2.0"
which "^1.2.9"
cryptiles@2.x.x:
version "2.0.5"
resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8"
@ -5451,6 +5460,10 @@ path-key@^2.0.0, path-key@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
path-key@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.0.tgz#99a10d870a803bdd5ee6f0470e58dfcd2f9a54d3"
path-parse@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"

Loading…
Cancel
Save