Browse Source

Remove offline plugin, continue work of aeeabb1

pull/12409/head
Wei Zhu 6 years ago
parent
commit
70ef4f28aa
  1. 22
      site/bisheng.config.js
  2. 19
      site/getExternalResources.js

22
site/bisheng.config.js

@ -1,10 +1,8 @@
const path = require('path');
const CSSSplitWebpackPlugin = require('css-split-webpack-plugin').default;
const OfflinePlugin = require('@yesmeck/offline-plugin');
const replaceLib = require('antd-tools/lib/replaceLib');
const webpack = require('webpack');
const WebpackBar = require('webpackbar');
const getExternalResources = require('./getExternalResources');
const isDev = process.env.NODE_ENV === 'development';
const usePreact = process.env.REACT_ENV === 'preact';
@ -132,26 +130,6 @@ module.exports = {
config.plugins.push(
new CSSSplitWebpackPlugin({ size: 4000 }),
new OfflinePlugin({
appShell: '/app-shell',
caches: {
main: [':rest:'],
additional: [':externals:'],
},
externals: [
'/app-shell',
'https://at.alicdn.com/t/font_148784_v4ggb6wrjmkotj4i.woff',
'https://at.alicdn.com/t/font_148784_v4ggb6wrjmkotj4i.eot',
'https://at.alicdn.com/t/font_148784_v4ggb6wrjmkotj4i.svg',
'https://at.alicdn.com/t/font_148784_v4ggb6wrjmkotj4i.ttf',
].concat(getExternalResources()),
responseStrategy: 'network-first',
safeToUseOptionalCaches: true,
ServiceWorker: {
events: true,
},
AppCache: false,
}),
);
return config;

19
site/getExternalResources.js

@ -1,19 +0,0 @@
const glob = require('glob');
const fs = require('fs');
const { uniq } = require('lodash');
function getExternalResources() {
const files = glob.sync('{./{components,docs}/**/*.md,./site/**/*.{less,js,jsx}}');
const resources = files.reduce((acc, file) => {
const content = fs.readFileSync(file, 'utf-8');
const pattern = new RegExp('(https://.+\\.alipayobjects\\.com/.+\\.(png|jpg|svg)|)', 'mg');
const matches = content.match(pattern);
if (matches) {
acc = acc.concat(matches);
}
return acc;
}, []);
return uniq(resources);
}
module.exports = getExternalResources;
Loading…
Cancel
Save