-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.base.config.js
101 lines (99 loc) · 2.53 KB
/
webpack.base.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
'use strict';
const path = require('path');
const { EnvironmentPlugin } = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const { version } = require('./package.json');
const config = {
output: {
filename: '[name].[contenthash].js',
chunkFilename: '[contenthash].js',
clean: true,
},
resolve: {
extensions: ['.jsx', '.js', '.json'],
mainFields: ['generativeFmManifest', 'browser', 'module', 'main'],
alias: {
react: path.join(__dirname, 'node_modules/react'),
'react-router-dom': path.join(__dirname, 'node_modules/react-router-dom'),
'react-dom': path.join(__dirname, 'node_modules/react-dom'),
tone: path.join(__dirname, 'node_modules/tone'),
},
},
module: {
rules: [
{
test: /\.jsx?$/,
include: /src/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
},
},
},
{
enforce: 'pre',
test: /\.jsx?$/,
include: /src/,
use: { loader: 'eslint-loader', options: { emitWarning: true } },
},
{
test: /\.scss$/,
use: 'sass-loader',
},
{
test: /\.gfm.manifest.json$/,
use: [
{
loader: 'babel-loader',
options: {
plugins: ['@babel/plugin-syntax-dynamic-import'],
},
},
path.resolve('./piece-loader.js'),
],
include: /@generative-music\/piece-/,
type: 'javascript/auto',
},
{
test: /\.worker\.js$/,
use: 'worker-loader',
},
{
test: [/\.png$/, /\.mp3$/],
use: 'file-loader',
},
{
test: /\.png$/,
use: 'image-webpack-loader',
},
{
test: /\.js$/,
include: /node_modules\/tone/,
use: 'source-map-loader',
enforce: 'pre',
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.template.html',
favicons: {
appName: 'Generative.fm Record',
appDescription: 'Free ambient music, made to order by Generative.fm',
theme: '#1e1e1e',
background: '#121212',
},
}),
new FaviconsWebpackPlugin({
logo: './src/logo.png',
prefix: `icons/[contenthash]/`,
}),
new EnvironmentPlugin({
SAMPLE_FILE_HOST: '//localhost:6969',
APP_VERSION: version,
}),
],
};
module.exports = config;