From 8a174c3a06bf421090a2cdce66dc389bbc34d635 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 21 Aug 2019 14:38:53 +0800 Subject: [PATCH 1/5] cdn test --- public/react/scripts/build.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/public/react/scripts/build.js b/public/react/scripts/build.js index b2bac24ec..037b0ee42 100644 --- a/public/react/scripts/build.js +++ b/public/react/scripts/build.js @@ -194,7 +194,7 @@ function generateNewIndexJsp() { const newVersion = '1.1.1' let cdnHost = 'https://shixun.educoder.net' cdnHost = 'https://ali-cdn.educoder.net' - // cdnHost = '' + cdnHost = '' var result = data.replace('/js/js_min_all.js', `${cdnHost}/react/build/js/js_min_all.js?v=${newVersion}`) // .replace('/js/js_min_all_2.js', `${cdnHost}/react/build/js/js_min_all_2.js?v=${newVersion}`) @@ -207,11 +207,28 @@ function generateNewIndexJsp() { // .replace('/react/build/./static/css/main', `${cdnHost}/react/build/./static/css/main`) // .replace('/react/build/./static/js/main', `${cdnHost}/react/build/./static/js/main`) - .replace(/https:\/\/testeduplus2.educoder.net/g, ''); + // .replace(/https:\/\/testeduplus2.educoder.net/g, ''); // .replace(/http:\/\/testbdweb.educoder.net/g, ''); // .replace('/css/css_min_all.css', '/react/build/css/css_min_all.css'); + var mainRegex = / + ` + result = data.replace(mainRegex, code) + fs2.writeFile(outputPath, result, 'utf8', function (err) { if (err) return console.log(err); commitAndPush(); From 48e5f9f84b7c15b1e70951ed1d4fa72ba755dba0 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 21 Aug 2019 14:48:38 +0800 Subject: [PATCH 2/5] import './public-path.js'; --- public/react/src/App.js | 1 + public/react/src/public-path.js | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 public/react/src/public-path.js diff --git a/public/react/src/App.js b/public/react/src/App.js index 9621fdc18..3fd121268 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -1,4 +1,5 @@ import React, {Component} from 'react'; +import './public-path.js'; import logo from './logo.svg'; import './App.css'; import {LocaleProvider} from 'antd' diff --git a/public/react/src/public-path.js b/public/react/src/public-path.js new file mode 100644 index 000000000..fb82840d4 --- /dev/null +++ b/public/react/src/public-path.js @@ -0,0 +1,6 @@ +/*global __webpack_public_path__ */ +if (window.location.host == '47.96.87.25:48080') { + __webpack_public_path__ = 'http://testali-cdn.educoder.net/react/build/' +} else if (window.location.host == 'www.educoder.net') { + __webpack_public_path__ = 'https://ali-newweb.educoder.net/react/build/' +} \ No newline at end of file From 5b56c36344f17442eec8647fde0c24eb441f7a81 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 21 Aug 2019 15:16:47 +0800 Subject: [PATCH 3/5] \\ --- public/react/scripts/build.js | 42 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/public/react/scripts/build.js b/public/react/scripts/build.js index 037b0ee42..9ec7f5166 100644 --- a/public/react/scripts/build.js +++ b/public/react/scripts/build.js @@ -195,22 +195,7 @@ function generateNewIndexJsp() { let cdnHost = 'https://shixun.educoder.net' cdnHost = 'https://ali-cdn.educoder.net' cdnHost = '' - var result = data.replace('/js/js_min_all.js', `${cdnHost}/react/build/js/js_min_all.js?v=${newVersion}`) - // .replace('/js/js_min_all_2.js', `${cdnHost}/react/build/js/js_min_all_2.js?v=${newVersion}`) - - // ${cdnHost} 加了cdn后,这个文件里的字体文件加载会有跨域的报错 ../fonts/fontawesome-webfont.eot - // TODO tpi 评测结果关闭也使用了fontawesome - .replace('/css/css_min_all.css', `${cdnHost}/react/build/css/css_min_all.css?v=${newVersion}`) - .replace('/css/iconfont.css', `${cdnHost}/react/build/css/iconfont.css?v=${newVersion}`) - .replace(/\/js\/create_kindeditor.js/g, `${cdnHost}/react/build/js/create_kindeditor.js?v=${newVersion}`) - - // .replace('/react/build/./static/css/main', `${cdnHost}/react/build/./static/css/main`) - // .replace('/react/build/./static/js/main', `${cdnHost}/react/build/./static/js/main`) - - // .replace(/https:\/\/testeduplus2.educoder.net/g, ''); - // .replace(/http:\/\/testbdweb.educoder.net/g, ''); - - // .replace('/css/css_min_all.css', '/react/build/css/css_min_all.css'); + var mainRegex = / ` - result = data.replace(mainRegex, code) + var jsMinAllRegex = / + var result = data + .replace(jsMinAllRegex, '') + // .replace('/js/js_min_all.js', `${cdnHost}/react/build/js/js_min_all.js?v=${newVersion}`) + // .replace('/js/js_min_all_2.js', `${cdnHost}/react/build/js/js_min_all_2.js?v=${newVersion}`) + + // ${cdnHost} 加了cdn后,这个文件里的字体文件加载会有跨域的报错 ../fonts/fontawesome-webfont.eot + // TODO tpi 评测结果关闭也使用了fontawesome + .replace('/css/css_min_all.css', `${cdnHost}/react/build/css/css_min_all.css?v=${newVersion}`) + .replace('/css/iconfont.css', `${cdnHost}/react/build/css/iconfont.css?v=${newVersion}`) + .replace(/\/js\/create_kindeditor.js/g, `${cdnHost}/react/build/js/create_kindeditor.js?v=${newVersion}`) + + .replace(mainRegex, code) + // .replace('/react/build/./static/css/main', `${cdnHost}/react/build/./static/css/main`) + // .replace('/react/build/./static/js/main', `${cdnHost}/react/build/./static/js/main`) + + // .replace(/https:\/\/testeduplus2.educoder.net/g, ''); + // .replace(/http:\/\/testbdweb.educoder.net/g, ''); + + // .replace('/css/css_min_all.css', '/react/build/css/css_min_all.css'); fs2.writeFile(outputPath, result, 'utf8', function (err) { if (err) return console.log(err); From f794810ddd04348bfe10843a39da6d61e86dfaa6 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 21 Aug 2019 15:39:10 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/scripts/build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/scripts/build.js b/public/react/scripts/build.js index 9ec7f5166..fe18e93e5 100644 --- a/public/react/scripts/build.js +++ b/public/react/scripts/build.js @@ -208,8 +208,8 @@ function generateNewIndexJsp() { } else if (window.location.host == 'www.educoder.net') { _host = 'https://ali-newweb.educoder.net/react/build/' } - document.write(' ` From 6e9b9c62649f1cd77108049cdca41f91e37fc5e0 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 21 Aug 2019 15:39:30 +0800 Subject: [PATCH 5/5] js --- public/react/src/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/App.js b/public/react/src/App.js index 3fd121268..3949c26a2 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -1,5 +1,5 @@ import React, {Component} from 'react'; -import './public-path.js'; +import './public-path'; import logo from './logo.svg'; import './App.css'; import {LocaleProvider} from 'antd'