Webpack: bundle sounds as assets
This commit is contained in:
parent
19181f40c3
commit
3359bda7f8
|
@ -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',
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
|
|
|
@ -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'),
|
||||||
}],
|
}],
|
||||||
|
|
Loading…
Reference in New Issue