[ISSUE #8156] Add hash-tag for js and css (#8157)

* [ISSUE #8156] Add hash-tag for js and css

- add index.html to copyList
- use index.ejs instead of index.html
- webpack enable hash

Close #8156

* [ISSUE #8156] Fix context-path error in development environment

Close #8156
This commit is contained in:
onewe 2022-04-20 10:20:26 +08:00 committed by GitHub
parent 8838ae1417
commit af90533c8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 91 additions and 85 deletions

View File

@ -27,7 +27,7 @@ const mkdir = dir => {
} }
}; };
const copyList = ['js/main.js', 'css/main.css']; const copyList = ['js/main.js', 'css/main.css', 'index.html'];
copyList.forEach(_fileName => { copyList.forEach(_fileName => {
const srcFileName = path.join(srcDir, _fileName); const srcFileName = path.join(srcDir, _fileName);

View File

@ -95,7 +95,11 @@ module.exports = {
plugins: [ plugins: [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
filename: 'index.html', filename: 'index.html',
template: './public/index.html', template: './public/index.ejs',
templateParameters: {
contextPath: isDev ? './' : 'console-ui/public/'
},
hash: true,
minify: !isDev, minify: !isDev,
}), }),
new CopyWebpackPlugin([ new CopyWebpackPlugin([

View File

@ -0,0 +1,61 @@
<!--
~ Copyright 1999-2018 Alibaba Group Holding Ltd.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<title>Nacos</title>
<link rel="shortcut icon" href="<%= contextPath %>img/nacos-logo.png" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="<%= contextPath %>css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="<%= contextPath %>css/console1412.css">
<!-- 第三方css开始 -->
<link rel="stylesheet" type="text/css" href="<%= contextPath %>css/codemirror.css">
<link rel="stylesheet" type="text/css" href="<%= contextPath %>css/merge.css">
<link rel="stylesheet" type="text/css" href="<%= contextPath %>css/icon.css">
<link rel="stylesheet" type="text/css" href="<%= contextPath %>css/font-awesome.css">
<!-- 第三方css结束 -->
</head>
<body>
<div id="root" style="overflow:hidden"></div>
<div id="app"></div>
<div id="other"></div>
<!-- 第三方js开始 -->
<script src="<%= contextPath %>js/jquery.js"></script>
<script src="<%= contextPath %>js/codemirror.js"></script>
<script src="<%= contextPath %>js/javascript.js"></script>
<script src="<%= contextPath %>js/xml.js"></script>
<script src="<%= contextPath %>js/codemirror.addone.fullscreen.js"></script>
<script src="<%= contextPath %>js/codemirror.addone.lint.js"></script>
<script src="<%= contextPath %>js/codemirror.lib.json-lint.js"></script>
<script src="<%= contextPath %>js/codemirror.addone.json-lint.js"></script>
<script src="<%= contextPath %>js/codemirror.lib.clike-lint.js"></script>
<script src="<%= contextPath %>js/diff_match_patch.js"></script>
<script src="<%= contextPath %>js/merge.js"></script>
<script src="<%= contextPath %>js/loader.js"></script>
<!-- 第三方js结束 -->
</body>
</html>

View File

@ -1,58 +0,0 @@
<!--
~ Copyright 1999-2018 Alibaba Group Holding Ltd.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Nacos</title>
<link rel="shortcut icon" href="img/nacos-logo.png" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/console1412.css">
<!-- 第三方css开始 -->
<link rel="stylesheet" type="text/css" href="css/codemirror.css">
<link rel="stylesheet" type="text/css" href="css/merge.css">
<link rel="stylesheet" type="text/css" href="css/icon.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome.css">
<!-- 第三方css结束 -->
</head>
<body>
<div id="root" style="overflow:hidden"></div>
<div id="app"></div>
<div id="other"></div>
<!-- 第三方js开始 -->
<script src="js/jquery.js"></script>
<script src="js/codemirror.js"></script>
<script src="js/javascript.js"></script>
<script src="js/xml.js"></script>
<script src="js/codemirror.addone.fullscreen.js"></script>
<script src="js/codemirror.addone.lint.js"></script>
<script src="js/codemirror.lib.json-lint.js"></script>
<script src="js/codemirror.addone.json-lint.js"></script>
<script src="js/codemirror.lib.clike-lint.js"></script>
<script src="js/diff_match_patch.js"></script>
<script src="js/merge.js"></script>
<script src="js/loader.js"></script>
<!-- 第三方js结束 -->
</body>
</html>

View File

@ -22,20 +22,20 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>Nacos</title> <title>Nacos</title>
<link rel="shortcut icon" href="console-ui/public/img/nacos-logo.png" type="image/x-icon"> <link rel="shortcut icon" href="console-ui/public/img/nacos-logo.png" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="console-ui/public/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/console1412.css"> <link rel="stylesheet" type="text/css" href="console-ui/public/css/console1412.css">
<!-- 第三方css开始 --> <!-- 第三方css开始 -->
<link rel="stylesheet" type="text/css" href="console-ui/public/css/codemirror.css"> <link rel="stylesheet" type="text/css" href="console-ui/public/css/codemirror.css">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/merge.css"> <link rel="stylesheet" type="text/css" href="console-ui/public/css/merge.css">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/icon.css"> <link rel="stylesheet" type="text/css" href="console-ui/public/css/icon.css">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/font-awesome.css"> <link rel="stylesheet" type="text/css" href="console-ui/public/css/font-awesome.css">
<!-- 第三方css结束 --> <!-- 第三方css结束 -->
<link href="css/main.css" rel="stylesheet"> <link href="./css/main.css?70f1002598390a0fe1c6" rel="stylesheet"></head>
</head>
<body> <body>
<div id="root" style="overflow:hidden"></div> <div id="root" style="overflow:hidden"></div>
@ -55,8 +55,7 @@
<script src="console-ui/public/js/diff_match_patch.js"></script> <script src="console-ui/public/js/diff_match_patch.js"></script>
<script src="console-ui/public/js/merge.js"></script> <script src="console-ui/public/js/merge.js"></script>
<script src="console-ui/public/js/loader.js"></script> <script src="console-ui/public/js/loader.js"></script>
<!-- 第三方js结束 --> <!-- 第三方js结束 -->
<script type="text/javascript" src="js/main.js"></script></body> <script type="text/javascript" src="./js/main.js?70f1002598390a0fe1c6"></script></body>
</html> </html>