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

View File

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

View File

@ -1,15 +1,16 @@
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 {
private readonly _binaries: YMap<YArray<ArrayBuffer>>; // binary instance
private readonly _remoteStorage?: RemoteKvService;
constructor(binaries: YMap<YArray<ArrayBuffer>>, remote_token?: string) {
constructor(binaries: YMap<YArray<ArrayBuffer>>, remoteToken?: string) {
this._binaries = binaries;
if (remote_token) {
this._remoteStorage = new RemoteKvService(remote_token);
if (remoteToken) {
// TODO: remote kv need to refactor, we may use cloudflare kv
// this._remoteStorage = new RemoteKvService(remote_token);
} else {
console.warn(`Remote storage is not ready`);
}