Skip to content

Commit 1be69ce

Browse files
Support findCubismDir
1 parent d493fb5 commit 1be69ce

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

rollup.config.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
import terser from '@rollup/plugin-terser';
22
import alias from '@rollup/plugin-alias';
3+
import fs from 'fs';
34
import path from 'path';
45
import { fileURLToPath } from 'url';
56

67
const __dirname = path.dirname(fileURLToPath(import.meta.url));
78

8-
function banner() {
9+
function findCubismDir() {
10+
const buildDir = path.join(__dirname, 'build');
11+
let candidates = fs.readdirSync(buildDir)
12+
.filter(f => f.startsWith('CubismSdkForWeb-') && fs.statSync(path.join(buildDir, f)).isDirectory());
13+
if (candidates.length === 0) {
14+
candidates = ['CubismSdkForWeb-5-r.4'];
15+
}
16+
return path.join(buildDir, candidates[0]);
17+
}
918

19+
const cubismDir = findCubismDir();
20+
21+
function banner() {
1022
return {
1123
name: 'banner',
1224

@@ -34,11 +46,11 @@ export default {
3446
entries: [
3547
{
3648
find: '@demo',
37-
replacement: path.resolve(__dirname, 'build/CubismSdkForWeb-5-r.4/Samples/TypeScript/Demo/src/')
49+
replacement: path.resolve(cubismDir, 'Samples/TypeScript/Demo/src/')
3850
},
3951
{
4052
find: '@framework',
41-
replacement: path.resolve(__dirname, 'build/CubismSdkForWeb-5-r.4/Framework/src/')
53+
replacement: path.resolve(cubismDir, 'Framework/src/')
4254
}
4355
]
4456
}),

0 commit comments

Comments
 (0)