62 lines
1.3 KiB
JavaScript
62 lines
1.3 KiB
JavaScript
const path = require('path');
|
|
const webpack = require('webpack');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const server = require('./server/index.js');
|
|
const { formatHeaders } = require('./server/headers.js');
|
|
|
|
const API_PORT = 8888;
|
|
const API_HOST = '127.0.0.1';
|
|
|
|
module.exports = {
|
|
context: path.resolve(__dirname, './src'),
|
|
mode: 'development',
|
|
entry: {
|
|
app: './app.js',
|
|
sw: './sw.js'
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, './dist'),
|
|
filename: '[name].bundle.js',
|
|
publicPath: '/'
|
|
},
|
|
devServer: {
|
|
before: () => {
|
|
server.app.listen(API_PORT, API_HOST);
|
|
console.log(`Running api host on ${API_HOST}:${API_PORT}`);
|
|
},
|
|
compress: true,
|
|
contentBase: path.join(__dirname, 'dist'),
|
|
headers: formatHeaders(),
|
|
host: '0.0.0.0',
|
|
https: true,
|
|
proxy: {
|
|
'/api': `http://${API_HOST}:${API_PORT}`
|
|
}
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.css$/,
|
|
loader: 'css-loader'
|
|
},
|
|
// fonts
|
|
{
|
|
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
loader: 'url-loader?limit=10000&minetype=application/font-woff'
|
|
},
|
|
{
|
|
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
loader: 'file-loader'
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new webpack.DefinePlugin({ __DEV__: true }),
|
|
new HtmlWebpackPlugin({
|
|
template: 'index.template.html',
|
|
inject: 'body'
|
|
})
|
|
],
|
|
devtool: 'source-map'
|
|
};
|