const path = require('path'); const webpack = require('webpack'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); 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}`); }, contentBase: path.join(__dirname, 'dist'), host: '0.0.0.0', https: true, headers: formatHeaders(), proxy: { '/api': `http://${API_HOST}:${API_PORT}` } }, module: { rules: [ { test: /\.css$/, use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: '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 ExtractTextPlugin('app.css', { allChunks: true }), new HtmlWebpackPlugin({ template: 'index.template.html', inject: 'body' }) ], devtool: 'source-map' };