1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-27 21:05:53 +00:00
FrankerFaceZ/webpack.web.dev.js

89 lines
1.7 KiB
JavaScript
Raw Normal View History

/* eslint-disable */
2017-11-13 01:23:39 -05:00
const path = require('path');
const merge = require('webpack-merge');
const common = require('./webpack.web.common.js');
const {exec} = require('child_process');
2017-11-13 01:23:39 -05:00
const CopyPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
2017-11-13 01:23:39 -05:00
/* global module */
2017-11-13 01:23:39 -05:00
module.exports = merge(common, {
mode: 'development',
2017-11-13 01:23:39 -05:00
devtool: 'inline-source-map',
plugins: [
new CopyPlugin([
{
from: './src/entry.js',
to: 'script.js'
}
]),
new webpack.DefinePlugin({
__git_commit__: null
})
2017-11-13 01:23:39 -05:00
],
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/',
2017-11-13 01:23:39 -05:00
changeOrigin: true
}
},
before(app) {
// Because the headers config option is broken.
app.get('/*', (req, res, next) => {
2017-11-13 01:23:39 -05:00
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);
});
});
2017-11-13 01:23:39 -05:00
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'
2017-11-13 01:23:39 -05:00
}
})