Skip to content
This repository was archived by the owner on Jan 16, 2022. It is now read-only.

Commit b9260cb

Browse files
authored
feat!: manifest over html in production build (#610)
1 parent bbe04c3 commit b9260cb

File tree

9 files changed

+293
-489
lines changed

9 files changed

+293
-489
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ jobs:
2626
run: yarn lint
2727
- name: Build
2828
run: yarn build
29-
- name: E2E
30-
run: yarn test:e2e
29+
# disabled temporary
30+
# - name: E2E
31+
# run: yarn test:e2e

htmllinter.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
const path = require('path');
22

33
module.exports = () => {
4-
return path.join(__dirname, 'static');
4+
return {
5+
staticPath: path.join(__dirname, 'static'),
6+
manifest: require('./static/manifest.json'),
7+
manifestFiles: {
8+
js: ['runtime.js', 'vendors.js', 'main.js'],
9+
},
10+
};
511
};

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
"@emotion/jest": "^11.1.0",
4444
"@emotion/styled": "10.0.27",
4545
"@emotion/styled-base": "^10.0.31",
46-
"@htmllinter/basic-config": "^0.5.1",
47-
"@htmllinter/core": "^0.5.1",
4846
"@material-ui/core": "4.11.2",
4947
"@material-ui/icons": "4.11.2",
5048
"@material-ui/styles": "^4.11.2",
@@ -157,11 +155,12 @@
157155
"verdaccio-auth-memory": "9.7.2",
158156
"verdaccio-memory": "9.7.2",
159157
"wait-on": "5.2.0",
160-
"webpack": "5.10.1",
158+
"webpack": "5.23.0",
161159
"webpack-bundle-analyzer": "3.8.0",
162160
"webpack-bundle-size-analyzer": "3.1.0",
163-
"webpack-cli": "~4.2.0",
161+
"webpack-cli": "~4.5.0",
164162
"webpack-dev-server": "^3.11.0",
163+
"webpack-manifest-plugin": "^3.0.0",
165164
"webpack-merge": "^5.6.1",
166165
"whatwg-fetch": "^3.4.1",
167166
"xss": "1.0.8"
@@ -194,7 +193,6 @@
194193
"test:size": "bundlesize",
195194
"lint": "yarn run lint:js && yarn run lint:css",
196195
"lint:js": "yarn run type-check && eslint . --ext .js,.ts,.tsx",
197-
"lint:html": "yarn htmllinter src/template/index.html",
198196
"lint:css": "yarn stylelint \"src/**/styles.ts\"",
199197
"coverage:publish": "codecov",
200198
"dev:web": "babel-node tools/dev.server.js",

src/providers/API/APIProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const APIProvider: FunctionComponent = ({ children }) => {
3737
const { configOptions } = useConfig();
3838

3939
const buildURL = (basePath: string) => {
40-
return `${configOptions?.base}/-/verdaccio/${basePath}`;
40+
return `${configOptions?.base}-/verdaccio/${basePath}`;
4141
};
4242

4343
const callReadme = async (packageName: string, packageVersion?: string): Promise<string> => {

tools/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
output: {
99
path: `${env.APP_ROOT}/static/`,
1010
filename: '[name].[fullhash].js',
11-
publicPath: '/-/static/',
11+
publicPath: '-/static/',
1212
},
1313

1414
resolve: {

tools/webpack.dev.config.babel.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,13 @@ export default {
3434
__APP_VERSION__: `"${getPackageJson('version')}"`,
3535
}),
3636
new HTMLWebpackPlugin({
37-
basePath: 'http://localhost:4872',
3837
__UI_OPTIONS: JSON.stringify({
39-
base: 'http://localhost:4872',
40-
protocol: 'http',
41-
host: 'localhost',
42-
primaryColor: '#4b5e40',
43-
url_prefix: '',
44-
darkMode: false,
45-
language: 'en-US',
46-
uri: 'http://localhost:4872',
4738
title: 'Verdaccio Dev UI',
4839
scope: '',
49-
version: 'v1.0.0',
40+
filename: 'index.html',
41+
verdaccioURL: '//localhost:4873/',
42+
base: 'https://localhost:4872/',
5043
}),
51-
title: 'Verdaccio Dev UI',
52-
filename: 'index.html',
53-
faviIcoPath: '/-/static/favicon.ico',
5444
template: `${env.SRC_ROOT}/template/index.html`,
5545
debug: true,
5646
inject: true,

tools/webpack.prod.config.babel.js

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
const HTMLWebpackPlugin = require('html-webpack-plugin');
2-
const _ = require('lodash');
3-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4-
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
51
const TerserPlugin = require('terser-webpack-plugin');
62
const webpack = require('webpack');
3+
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
74
const { merge } = require('webpack-merge');
85

96
const env = require('../config/env');
@@ -19,6 +16,7 @@ const banner = `
1916
Package: ${name}
2017
Version: v${version}
2118
License: ${license}
19+
https://www.verdaccio.org
2220
`;
2321

2422
const prodConf = {
@@ -38,27 +36,14 @@ const prodConf = {
3836
'process.env.NODE_ENV': '"production"',
3937
__APP_VERSION__: `"${version}"`,
4038
}),
41-
new MiniCssExtractPlugin({
42-
// Options similar to the same options in webpackOptions.output
43-
// both options are optional
44-
filename: '[name].[contenthash].css',
45-
chunkFilename: '[id].[contenthash].css',
46-
}),
47-
new HTMLWebpackPlugin({
48-
title: 'ToReplaceByTitle',
49-
basePath: 'ToReplaceByVerdaccio',
50-
faviIcoPath: `ToReplaceByVerdaccioFavico`,
51-
__UI_OPTIONS: 'ToReplaceByVerdaccioUI',
52-
filename: 'index.html',
53-
template: `${env.SRC_ROOT}/template/index.html`,
54-
debug: false,
55-
inject: true,
39+
new WebpackManifestPlugin({
40+
removeKeyHash: true,
5641
}),
5742
new webpack.BannerPlugin(banner),
5843
],
5944
optimization: {
6045
minimize: true,
61-
minimizer: [new TerserPlugin(), new OptimizeCSSAssetsPlugin({})],
46+
minimizer: [new TerserPlugin()],
6247
},
6348
performance: {
6449
hints: 'warning',
@@ -67,10 +52,4 @@ const prodConf = {
6752
},
6853
};
6954

70-
prodConf.module.rules = baseConfig.module.rules
71-
.filter(loader => Array.isArray(loader.use) && loader.use.find(v => /css/.test(v.loader.split('-')[0])))
72-
.forEach(loader => {
73-
loader.use = [MiniCssExtractPlugin.loader].concat(_.tail(loader.use));
74-
});
75-
7655
module.exports = merge(baseConfig, prodConf);

0 commit comments

Comments
 (0)