-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.common.js
65 lines (63 loc) · 1.68 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const path = require('path')
module.exports = {
entry: {
main: './src/index.js'
},
output: {
path: path.join(__dirname, 'dist'), // Give the Webpack outputted JS bundle files names dynamically *
filename: '[name].[contentHash].js' // Set the output path/location directory name for the bundle
},
module: {
rules: [
{
test: /\.html$/,
use: [
{
loader: 'html-loader', // Exports HTML as string
options: {
minimize: false // Minimize HTML
}
}
]
},
{
test: /favicon\.png$/, // Extract './favicon.png'
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: '' // Output path into the ./dist root directory
}
}
]
},
{
test: /(robots|humans)\.txt$/, // Extract './robots.txt' or './humans.txt'
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: '' // Output path into the ./dist root directory
}
}
]
},
{
test: /\.(svg|png|jpe?g|gif)$/,
exclude: /favicon\.png$/, // Exclude this file
use: [
{
loader: 'file-loader', // Emits the file into the output directory
options: {
name: '[name].[hash].[ext]',
outputPath: 'img' // output path into the dist directory
}
}
]
}
]
}
}
// * [name] are dynamically generated from the properties declared as entry points in webpack.common.js