-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config - Kopie (2).js
191 lines (182 loc) · 5.75 KB
/
webpack.config - Kopie (2).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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
const path = require('path');
const buildMode = process.env.NODE_ENV || 'development';
const buildTarget = process.env.TARGET || 'web';
const isProd = buildMode === 'production';
const sourcemapsMode = isProd ? 'eval-source-map' : undefined;
// Plugins
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
//const CSPWebpackPlugin = require('csp-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const useFriendly = true;
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const haxeFormatter = require('haxe-loader/errorFormatter');
const haxeTransformer = require('haxe-loader/errorTransformer');
const extractCSS = new ExtractTextPlugin('app.css');
// Options
const debugMode = buildMode !== 'production';
const dist = __dirname + '/bin/';
// Sourcemaps: https://webpack.js.org/configuration/devtool/
// - 'eval-source-map': fast, but JS bundle is somewhat obfuscated
// - 'source-map': slow, but JS bundle is readable
// - undefined: no map, and JS bundle is readable
console.log('isProd:' + isProd);
//
// Configuration:
// This configuration is still relatively minimalistic;
// each section has many more options
//
module.exports = {
// List all the JS modules to create
// They will all be linked in the HTML page
entry: {
app: './build.hxml'
},
mode: buildMode,
// Generation options (destination, naming pattern,...)
output: {
path: dist,
filename: 'app.js',
publicPath: '/'
},
// Module resolution options (alias, default paths,...)
resolve: {
modules: [path.resolve(__dirname, 'res/scss'), 'node_modules'],
extensions: ['.js', '.json']
},
// Sourcemaps option for development
devtool: sourcemapsMode,
// Live development server (serves from memory)
devServer: {
contentBase: dist,
compress: true,
host: '192.168.178.56',
https: true,
port: 9000,
overlay: true,
hot: true,
inline: true,
headers: {
"Access-Control-Allow-Origin": "https://pitverwaltung.de"
},
watchOptions:{
aggregateTimeout:1500
},
historyApiFallback: {
index: 'index.html',
rewrites:[
{from: /./, to: '/index.html'}
]
}
},
//watch: true,
watchOptions:{
aggregateTimeout:1500,
//poll: 1500
},
// List all the processors
module: {
rules: [
// Haxe loader (through HXML files for now)
{
test: /\.hxml$/,
loader: 'haxe-loader',
options: {
// Additional compiler options added to all builds
extra: '-D build_mode=' + buildMode,
debug: debugMode
}
},
// Static assets loader
// - you will need to adjust for webfonts
// - you may use 'url-loader' instead which can replace
// small assets with data-urls
{
test: /\.(gif|png|jpg|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[hash:7].[ext]'
}
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
},
// CSS processor/loader
// - this is where you can add sass/less processing,
// - also consider adding postcss-loader for autoprefixing
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
isProd
? {
test: /\.scss$/,
loader: extractCSS.extract({
fallback: "style-loader",
use: [
{loader: 'css-loader'},
{
loader: 'sass-loader',
options: {
includePaths: [path.resolve(__dirname, 'res/scss'), path.resolve(__dirname, 'src')]
}
}
]
})
}
: {
test: /\.scss$/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'},
{
loader: 'sass-loader',
options: {
includePaths: [path.resolve(__dirname, 'res/scss'), path.resolve(__dirname, 'src')]
}
}
]
}
]
},
// Plugins can hook to the compiler lifecycle and handle extra tasks
plugins: [
// HMR: enable globally
new webpack.HotModuleReplacementPlugin(),
// HMR: prints more readable module names in the browser console on updates
new webpack.NamedModulesPlugin(),
// HMR: do not emit compiled assets that include errors
new webpack.NoEmitOnErrorsPlugin(),
// Like generating the HTML page with links the generated JS files
new HtmlWebpackPlugin({
filename: dist + './index.html',
template: __dirname + '/src/index.html',
title: 'Xpress CRM'
})
// You may want to also:
// - minify/uglify the output using UglifyJSPlugin,
// - extract the small CSS chunks into a single file using ExtractTextPlugin
// - avoid modules duplication using CommonsChunkPlugin
// - inspect your JS output weight using BundleAnalyzerPlugin
].concat(useFriendly ? [
new FriendlyErrorsWebpackPlugin({
compilationSuccessInfo: {
messages: [
`Your application is running here: https://localhost:${9000}`
]
},
additionalTransformers: [haxeTransformer],
additionalFormatters: [haxeFormatter]
})
] : [])
.concat(isProd ? [extractCSS] : []),
};