-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}), | ||
]; | ||
} |