Skip to content

Commit

Permalink
use local excalidraw
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum committed Nov 23, 2024
1 parent 3ed9a69 commit 260aaa9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/lexical-playground/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default defineConfig(({command}) => {
presets: [['@babel/preset-react', {runtime: 'automatic'}]],
}),
react(),
...viteCopyExcalidrawAssets('dev'),
...viteCopyExcalidrawAssets(),
viteCopyEsm(),
commonjs({
// This is required for React 19 (at least 19.0.0-beta-26f2496093-20240514)
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-playground/vite.prod.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default defineConfig({
presets: [['@babel/preset-react', {runtime: 'automatic'}]],
}),
react(),
...viteCopyExcalidrawAssets('prod'),
...viteCopyExcalidrawAssets(),
viteCopyEsm(),
commonjs({
// This is required for React 19 (at least 19.0.0-beta-26f2496093-20240514)
Expand Down
53 changes: 53 additions & 0 deletions packages/lexical-playground/viteCopyExcalidrawAssets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import type {Plugin} from 'vite';

import {createRequire} from 'node:module';
import * as path from 'node:path';
import {Target, viteStaticCopy} from 'vite-plugin-static-copy';

const require = createRequire(import.meta.url);

export default function viteCopyExcalidrawAssets(): Plugin[] {
const targets: Target[] = [
'excalidraw-assets',
'excalidraw-assets-dev',
].flatMap((assetDir) => {
const srcDir = path.join(
require.resolve('@excalidraw/excalidraw'),
'..',
'dist',
assetDir,
);
return [
{
dest: `${assetDir}/`,
src: [path.join(srcDir, '*.js'), path.join(srcDir, '*.woff2')],
},
{
dest: `${assetDir}/locales/`,
src: [path.join(srcDir, 'locales', '*.js')],
},
];
});
return [
{
config() {
return {
define: {
'process.env.EXCALIDRAW_ASSET_PATH': JSON.stringify('/'),
},
};
},
name: 'viteCopyExcalidrawAssets',
},
...viteStaticCopy({
targets,
}),
];
}

0 comments on commit 260aaa9

Please sign in to comment.