Skip to content

Commit 7763118

Browse files
committed
use cdn for script and style file
1 parent cd140fd commit 7763118

File tree

7 files changed

+29
-286
lines changed

7 files changed

+29
-286
lines changed

dist/public/main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/public/site.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/AppContainer/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const AppContainer = ({ url, children, criticalCss }) => (
2424
year={leftNavText[0]}
2525
favIconPngUrl={favIconPngUrl}
2626
favIconSvgUrl={favIconSvgUrl}
27-
script={`${publicPath}/${topNavDict[url].asset}.js?${process.env.version}`}
28-
style={`${publicPath}/${topNavDict[url].asset}.css?${process.env.version}`}
27+
script={`${publicPath}/${topNavDict[url].asset}.js`}
28+
style={`${publicPath}/${topNavDict[url].asset}.css`}
2929
lastBuildDate={process.env.lastBuildDate}
3030
criticalCss={criticalCss}
3131
author={author}

src/config.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
import { name, author as username, version } from '../package.json';
2+
3+
const repoUrl = `${username}/${name}`;
4+
const assetDirectory = 'dist/public';
5+
16
export const port = process.env.PORT || 3000;
27
/* istanbul ignore next */
38
export const staticFolder =
49
process.env.NODE_ENV === 'development' ? 'local' : 'dist';
510
export const renderOutputFolder = 'dist/views';
6-
export const publicPath = '/assets';
11+
/* istanbul ignore next */
12+
export const publicPath =
13+
process.env.NODE_ENV === 'development'
14+
? '/assets'
15+
: `https://cdn.jsdelivr.net/gh/${repoUrl}@v${version}/${assetDirectory}`;
716
export const iconCdnUrl = '//dkny.oss-cn-hangzhou.aliyuncs.com/1/icons';
817
export const nonLazyImg = 0;
918
export const favIconSvgUrl = `${iconCdnUrl}/deno.svg`; // [fav.ico, deno-fav.png]
@@ -13,7 +22,7 @@ export const pageSpeedUrl =
1322
'https://developers.google.com/speed/pagespeed/insights/?url=www.javascript.fun&tab=desktop';
1423
export const hideGithubCorner = false;
1524
export const githubUrl = 'https://github.com';
16-
export const gitRepo = `${githubUrl}/im6/javascript-fun`;
25+
export const gitRepo = `${githubUrl}/${repoUrl}`;
1726
export const defaultIcon = ['github0.png', 'github1.svg', 'github2.svg'][2];
1827

1928
/* istanbul ignore next */
@@ -82,8 +91,8 @@ export const viewModelPath = {
8291
};
8392

8493
export const criticalCssPath = {
85-
git: 'dist/public/main.css',
86-
site: 'dist/public/site.css',
94+
git: `${assetDirectory}/main.css`,
95+
site: `${assetDirectory}/site.css`,
8796
};
8897

8998
// crawler config

webpack/develop.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ const server = Object.assign(serverBaseConfig, devBase, {
101101
plugins: [
102102
new CleanWebpackPlugin(),
103103
new webpack.DefinePlugin({
104-
'process.env.version': JSON.stringify(Date.now().toString()),
105104
'process.env.lastBuildDate': JSON.stringify(
106105
`${new Date().toLocaleString()} EST`
107106
),

webpack/production.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
44
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
55
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
66
const autoprefixer = require('autoprefixer');
7-
const { v4: uuidv4 } = require('uuid');
87

98
const {
109
clientBaseConfig,
@@ -112,7 +111,6 @@ const server = Object.assign(serverBaseConfig, prodBase, {
112111
plugins: [
113112
new CleanWebpackPlugin(),
114113
new webpack.DefinePlugin({
115-
'process.env.version': JSON.stringify(uuidv4().substring(0, 8)),
116114
'process.env.lastBuildDate': JSON.stringify(
117115
`${new Date().toLocaleString()} EST`
118116
),

0 commit comments

Comments
 (0)