-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.common.js
42 lines (41 loc) · 1.03 KB
/
webpack.common.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
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const path = require('path');
module.exports = {
entry: {
app: './src/js/app.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
clean: true,
filename: './js/app.js',
},
module: {
rules: [
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader, // Extract CSS in production
'css-loader',
],
},
{
test: /\.(mp3|wav|ogg)$/, // Match audio file types
type: 'asset/resource', // Use Webpack's asset/resource loader for static assets
generator: {
filename: 'audio/[name][ext]', // Output to 'dist/audio' directory
},
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/[name].css', // Output CSS files
}),
new CopyPlugin({
patterns: [
{ from: 'src/audio', to: 'audio' }, // Ensure all files in 'audio' are copied to 'dist/audio'
],
}),
],
};