-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.dev.js
More file actions
105 lines (96 loc) · 3.04 KB
/
webpack.dev.js
File metadata and controls
105 lines (96 loc) · 3.04 KB
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
import path from 'path';
import fs from 'fs';
import { execSync } from 'child_process';
import { merge } from 'webpack-merge';
import common from './webpack.common.js';
const scriptName = 'tepsi';
const entry = {
'build.dev.js': path.join(common.context, 'src/js/index.js'),
'build.dev.junk': path.join(common.context, 'src/scss/main.scss')
};
const devServerConfig = {
type: 'http',
host: 'localhost',
port: 9004,
get target () {
return `${this.type}://${this.host}:${this.port}`;
},
sslPath: {
cert: `/etc/ssl/localcerts/${scriptName}.dev.pem`,
key: `/etc/ssl/localcerts/${scriptName}.dev-key.pem`
},
options: {}
};
if(fs.existsSync(devServerConfig.sslPath.cert) && fs.existsSync(devServerConfig.sslPath.key)){
devServerConfig.type = 'https';
devServerConfig.host = `${scriptName}.dev`;
devServerConfig.options = {
cert: fs.readFileSync(devServerConfig.sslPath.cert),
key: fs.readFileSync(devServerConfig.sslPath.key)
};
}
let browserApp;
try { execSync('which firefox', { stdio: 'ignore' }); browserApp = 'firefox'; } catch {}
export default merge(common, {
mode: 'development',
// Filesystem Cache — değişmeyen dosyaları yeniden derlemez, rebuild'leri dramatik hızlandırır.
cache: { type: 'filesystem' },
// Source Map Hafifletmesi (Hız Aşırtma)
// Ağır source-map yerine, dev modunda çok daha hızlı çalışan bu versiyonu kullanıyoruz.
devtool: 'eval-cheap-module-source-map',
// İzleme (Watch) Kısıtlamaları
watchOptions: {
// Claude'un ve gereksiz klasörlerin izlenmesini tamamen yasaklıyoruz
ignored: ['**/node_modules', '**/.claude/**', '**/.git/**', '**/*.log'],
// Ufak değişikliklerde anında derlemek yerine 600 milisaniye bekleyip topluca derler.
// Bu, tarayıcıya üst üste DDOS atılmasını engeller.
aggregateTimeout: 600,
},
entry,
output: {
filename: '[name]',
path: path.join(common.context, 'dev'),
library: {
name: 'Tepsi',
type: 'umd',
export: 'default'
},
globalObject: 'this'
},
devServer: {
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',
},
server: {
type: devServerConfig.type,
options: devServerConfig.options
},
host: '0.0.0.0',
allowedHosts: [devServerConfig.host, 'localhost', '127.0.0.1'],
port: devServerConfig.port,
devMiddleware: {
publicPath: '/_hot/'
},
open: {
target: [devServerConfig.target],
...(browserApp && { app: { name: browserApp } })
},
hot: false,
liveReload: true,
// Dev modunda gzip sıkıştırma gereksiz CPU yükü — tarayıcıya ham gönder.
compress: false,
static: [
{ directory: path.join(common.context, 'dev') },
{ directory: path.join(common.context, 'docs') }
],
client: {
overlay: {
errors: true,
warnings: true,
runtimeErrors: false
}
}
}
});