-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·105 lines (104 loc) · 2.63 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
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
102
103
104
105
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const LicenseCheckerWebpackPlugin = require('license-checker-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
module.exports = (env, argv) => ({
entry: {
app: './src/app/index.js',
loader: './src/loader/loader.js'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: ({ chunk }) => {
if (chunk.name === 'app') {
return '[name].[contenthash].js'
}
return '[name].js'
},
chunkFilename: '[name].js', // Neu hinzugefügt
publicPath: ''
},
target: 'web',
devtool: 'source-map',
module: {
rules: [
{
test: /(?!node_modules).*\.jsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader?cacheDirectory=false',
options: {
babelrc: true
}
}
]
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader']
},
{
test: /\.scss$/i,
use: ['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][contenthash].[ext]',
publicPath: '../'
}
}
]
},
{
test: /\.(otf)$/,
use: {
loader: 'url-loader'
}
},
{
test: /\.(eot|woff|woff2|ttf|svg)(\?[\s\S]+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][contenthash].[ext]',
publicPath: '../'
}
}
]
}
]
},
devServer: {
port: 8080,
devMiddleware: {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'
}
}
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/app/template.html',
excludeChunks: ['loader'],
templateParameters: {
host: 'http://localhost:8080'
}
}),
new LicenseCheckerWebpackPlugin({
outputFilename: 'licenses.txt',
allow: '(Apache-2.0 OR BSD-2-Clause OR BSD-3-Clause OR MIT OR 0BSD)',
filter: /(^.*[/\\]node_modules[/\\]((?:@[^/\\]+[/\\])?(?:[^@/\\][^/\\]*)))/
}),
new CleanWebpackPlugin()
]
}
)