Skip to content

Commit

Permalink
build: 手动分包
Browse files Browse the repository at this point in the history
  • Loading branch information
liningzhu committed Jan 8, 2024
1 parent f8d690d commit 9e585d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { toast } from '@/components'
import { INSTRUMENT_PERCUSSION_KEY } from '@/pages/settings/config/controller.config'
import { useStore } from '@/utils/hooks/use-store'
import { DrumPlayer } from '@buitar/tone-player'
Expand Down
14 changes: 14 additions & 0 deletions packages/buitar/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default defineConfig({
clientsClaim: true,
skipWaiting: true,
globPatterns: ['**/*.{js,css,html,mp3,ogg,ico}'],
maximumFileSizeToCacheInBytes: 2 * 1024 * 1024, // 2MB,最大预缓存文件大小
},
manifest: {
name: 'Buitar',
Expand Down Expand Up @@ -95,6 +96,19 @@ export default defineConfig({
build: {
outDir: 'dist',
minify: true,
rollupOptions: {
output: {
manualChunks: {
tone: ['tone'],
vexflow: ['vexflow'],
'react-libs': ['react', 'react-dom', 'react-router-dom'],
// 'buitar-libs': ['@buitar/abc-editor', '@buitar/to-guitar', '@buitar/tone-player'],
'@buitar/abc-editor':['@buitar/abc-editor'],
'@buitar/to-guitar':['@buitar/to-guitar'],
'@buitar/tone-player':['@buitar/tone-player'],
},
},
},
},
server: {
port: 8282,
Expand Down
5 changes: 1 addition & 4 deletions packages/tone-player/src/tone-player.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import * as Tone from 'tone'
import { instrumentConfig, instrumentType } from './tone.config'
import type { PolySynth } from 'tone'
import type { Instrument, StringsInstrument } from './instrument.type'
import type { Point } from '@buitar/to-guitar'

// import '../samples/index'

/**
* time
* 1m: 一个小节 measure
Expand All @@ -16,7 +13,7 @@ import type { Point } from '@buitar/to-guitar'
* Tone.Transport.timeSignature = 3 拍数(3/4拍)
*/
export class TonePlayer extends Tone.Sampler {
private _sampler: Tone.Sampler | PolySynth = new Tone.PolySynth(Tone.Synth).toDestination()
private _sampler: Tone.Sampler | Tone.PolySynth = new Tone.PolySynth(Tone.Synth).toDestination()
private instrument: Instrument = 'default'
static baseUrl: String = '/'

Expand Down

0 comments on commit 9e585d6

Please sign in to comment.