forked from MasterKale/a-frame-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
71 lines (70 loc) · 1.71 KB
/
webpack.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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
mode: 'development',
entry: {
// Global JS
global: './src/global.js',
// Page-specific JS
index: './src/index.js',
},
output: {
path: path.resolve(__dirname, 'docs'),
filename: '[name].[hash].js',
// Use absolute paths for assets, I uncomment this when building
// publicPath: '/A-Frame-Character-Editor/',
},
module: {
rules: [
{
test: /\.html$/,
use: {
loader: 'html-loader',
options: {
attrs: [
'img:src',
'audio:src',
],
}
}
},
{
test: /\.(jpe?g|png|mp3|wav|glb)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]?[hash:7]',
context: 'src',
},
},
],
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
]
},
plugins: [
// Clean docs/ on each build
new CleanWebpackPlugin(['docs']),
// Add HtmlWebpackPlugin entries to build individual HTML pages
new HtmlWebpackPlugin({
// Input path
template: 'src/index.html',
// Output (within docs/)
filename: 'index.html',
// Inject compiled JS into <head> (as per A-Frame docs)
inject: 'head',
// Specify which JS files, by key in `entry`, should be injected into the page
chunks: ['global', 'index'],
}),
],
// Settings for webpack-dev-server
devServer: {
clientLogLevel: 'info',
open: true,
},
};