Webpack: bundle sounds as assets

This commit is contained in:
Alex Gleason 2021-09-10 17:23:37 -05:00
parent 19181f40c3
commit 3359bda7f8
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 4 additions and 10 deletions

View File

@ -1,8 +1,5 @@
'use strict'; 'use strict';
import { join } from 'path';
import { FE_SUBDIRECTORY } from 'soapbox/build_config';
const createAudio = sources => { const createAudio = sources => {
const audio = new Audio(); const audio = new Audio();
sources.forEach(({ type, src }) => { sources.forEach(({ type, src }) => {
@ -31,21 +28,21 @@ export default function soundsMiddleware() {
const soundCache = { const soundCache = {
boop: createAudio([ boop: createAudio([
{ {
src: join(FE_SUBDIRECTORY, '/sounds/boop.ogg'), src: require('../../sounds/boop.ogg'),
type: 'audio/ogg', type: 'audio/ogg',
}, },
{ {
src: join(FE_SUBDIRECTORY, '/sounds/boop.mp3'), src: require('../../sounds/boop.mp3'),
type: 'audio/mpeg', type: 'audio/mpeg',
}, },
]), ]),
chat: createAudio([ chat: createAudio([
{ {
src: join(FE_SUBDIRECTORY, '/sounds/chat.oga'), src: require('../../sounds/chat.oga'),
type: 'audio/ogg', type: 'audio/ogg',
}, },
{ {
src: join(FE_SUBDIRECTORY, '/sounds/chat.mp3'), src: require('../../sounds/chat.mp3'),
type: 'audio/mpeg', type: 'audio/mpeg',
}, },
]), ]),

View File

@ -89,9 +89,6 @@ module.exports = {
new HtmlWebpackHarddiskPlugin(), new HtmlWebpackHarddiskPlugin(),
new CopyPlugin({ new CopyPlugin({
patterns: [{ patterns: [{
from: join(__dirname, '../app/sounds'),
to: join(output.path, 'sounds'),
}, {
from: join(__dirname, '../app/instance'), from: join(__dirname, '../app/instance'),
to: join(output.path, 'instance'), to: join(output.path, 'instance'),
}], }],