chore: ci fix & module split

This commit is contained in:
DarkSky
2022-08-24 04:14:14 +08:00
parent a81456450f
commit 86d4449db4
3 changed files with 26 additions and 39 deletions

View File

@@ -43,6 +43,7 @@ module.exports = function (webpackConfig) {
...config.output, ...config.output,
filename: '[name].[contenthash:8].js', filename: '[name].[contenthash:8].js',
chunkFilename: '[name].[chunkhash:8].js', chunkFilename: '[name].[chunkhash:8].js',
hashDigestLength: 8,
hashFunction: undefined, hashFunction: undefined,
}; };
config.optimization = { config.optimization = {
@@ -67,21 +68,21 @@ module.exports = function (webpackConfig) {
chunks: 'all', chunks: 'all',
enforce: true, enforce: true,
}, },
auth: { // auth: {
test: /[\\/]node_modules[\\/](@authing|@?firebase)/, // test: /[\\/]node_modules[\\/](@authing|@?firebase)/,
name: 'auth', // name: 'auth',
priority: -5, // priority: -5,
chunks: 'all', // chunks: 'all',
}, // },
edgeless: { edgeless: {
test: /(libs\/components\/board-|[\\/]node_modules[\\/]@tldraw)/, test: /(libs\/components\/board-|[\\/]node_modules[\\/]@tldraw)/,
name: 'edgeless', name: 'edgeless',
priority: -7, priority: -7,
chunks: 'all', chunks: 'all',
}, },
editor: { paper: {
test: /(libs\/framework\/(ligo|virgo|editor)|[\\/]node_modules[\\/](@codemirror|@lezer|slate))/, test: /(libs\/framework\/(ligo|virgo|editor)|[\\/]node_modules[\\/](@codemirror|@lezer|slate))/,
name: 'editor', name: 'paper',
priority: -8, priority: -8,
chunks: 'all', chunks: 'all',
}, },
@@ -176,7 +177,11 @@ module.exports = function (webpackConfig) {
publicPath: '/', publicPath: '/',
}), }),
new Style9Plugin(), new Style9Plugin(),
isProd && new MiniCssExtractPlugin(), isProd &&
new MiniCssExtractPlugin({
filename: '[name].[contenthash:8].css',
chunkFilename: '[id].[chunkhash:8].css',
}),
isProd && isProd &&
new CompressionPlugin({ new CompressionPlugin({
test: /\.(js|css|html|svg|ttf|woff)$/, test: /\.(js|css|html|svg|ttf|woff)$/,

View File

@@ -39,6 +39,7 @@ module.exports = function (webpackConfig) {
...config.output, ...config.output,
filename: '[name].[contenthash:8].js', filename: '[name].[contenthash:8].js',
chunkFilename: '[name].[chunkhash:8].js', chunkFilename: '[name].[chunkhash:8].js',
hashDigestLength: 8,
hashFunction: undefined, hashFunction: undefined,
}; };
config.optimization = { config.optimization = {
@@ -98,22 +99,7 @@ module.exports = function (webpackConfig) {
}, },
], ],
}); });
config.module.rules.unshift({ config.module.rules.splice(4);
test: /\.scss$/i,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
sourceMap: false,
},
},
{
loader: 'postcss-loader',
},
],
});
config.module.rules.splice(6);
} else { } else {
config.output = { config.output = {
...config.output, ...config.output,
@@ -155,7 +141,11 @@ module.exports = function (webpackConfig) {
template: path.resolve(__dirname, './src/template.html'), template: path.resolve(__dirname, './src/template.html'),
publicPath: '/', publicPath: '/',
}), }),
isProd && new MiniCssExtractPlugin(), isProd &&
new MiniCssExtractPlugin({
filename: '[name].[contenthash:8].css',
chunkFilename: '[id].[chunkhash:8].css',
}),
isProd && isProd &&
new CompressionPlugin({ new CompressionPlugin({
test: /\.(js|css|html|svg|ttf|woff)$/, test: /\.(js|css|html|svg|ttf|woff)$/,
@@ -201,15 +191,6 @@ const addEmotionBabelPlugin = config => {
// See https://github.com/mui/material-ui/issues/27380#issuecomment-928973157 // See https://github.com/mui/material-ui/issues/27380#issuecomment-928973157
// See https://github.com/emotion-js/emotion/tree/main/packages/babel-plugin#importmap // See https://github.com/emotion-js/emotion/tree/main/packages/babel-plugin#importmap
importMap: { importMap: {
'@toeverything/components/ui': {
styled: {
canonicalImport: ['@emotion/styled', 'default'],
styledBaseImport: [
'@toeverything/components/ui',
'styled',
],
},
},
'@mui/material': { '@mui/material': {
styled: { styled: {
canonicalImport: ['@emotion/styled', 'default'], canonicalImport: ['@emotion/styled', 'default'],

View File

@@ -1,15 +1,16 @@
import { Array as YArray, Map as YMap } from 'yjs'; import { Array as YArray, Map as YMap } from 'yjs';
import { RemoteKvService } from '@toeverything/datasource/remote-kv'; import type { RemoteKvService } from '@toeverything/datasource/remote-kv';
export class YjsRemoteBinaries { export class YjsRemoteBinaries {
private readonly _binaries: YMap<YArray<ArrayBuffer>>; // binary instance private readonly _binaries: YMap<YArray<ArrayBuffer>>; // binary instance
private readonly _remoteStorage?: RemoteKvService; private readonly _remoteStorage?: RemoteKvService;
constructor(binaries: YMap<YArray<ArrayBuffer>>, remote_token?: string) { constructor(binaries: YMap<YArray<ArrayBuffer>>, remoteToken?: string) {
this._binaries = binaries; this._binaries = binaries;
if (remote_token) { if (remoteToken) {
this._remoteStorage = new RemoteKvService(remote_token); // TODO: remote kv need to refactor, we may use cloudflare kv
// this._remoteStorage = new RemoteKvService(remote_token);
} else { } else {
console.warn(`Remote storage is not ready`); console.warn(`Remote storage is not ready`);
} }