forked from FrankerFaceZ/FrankerFaceZ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.web.dev.js
89 lines (73 loc) · 1.66 KB
/
webpack.web.dev.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
/* eslint-disable */
const path = require('path');
const merge = require('webpack-merge');
const common = require('./webpack.web.common.js');
const {exec} = require('child_process');
const CopyPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
/* global module */
module.exports = merge(common, {
mode: 'development',
devtool: 'inline-source-map',
plugins: [
new CopyPlugin([
{
from: './src/entry.js',
to: 'script.js'
}
]),
new webpack.DefinePlugin({
__git_commit__: null
})
],
devServer: {
https: true,
port: 8000,
compress: true,
inline: false,
allowedHosts: [
'.twitch.tv',
'.frankerfacez.com'
],
contentBase: path.join(__dirname, 'dev_cdn'),
publicPath: '/script/',
proxy: {
'**': {
target: 'https://cdn.frankerfacez.com/',
changeOrigin: true
}
},
before(app) {
// Because the headers config option is broken.
app.get('/*', (req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
});
app.get('/update_font', (req, res) => {
const proc = exec('npm run font:save');
proc.stdout.on('data', data => {
console.log('FONT>>', data);
});
proc.stderr.on('data', data => {
console.error('FONT>>', data);
});
proc.on('close', code => {
console.log('FONT>> Exited with code', code);
res.redirect(req.headers.referer);
});
});
app.get('/dev_server', (req, res) => {
res.json({
path: process.cwd(),
version: 2
})
});
}
},
output: {
publicPath: '//localhost:8000/script/',
filename: '[name].js',
jsonpFunction: 'ffzWebpackJsonp',
crossOriginLoading: 'anonymous'
}
})