qpa-server/client/webpack.config.ts

64 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-04-19 19:12:05 +02:00
import * as webpack from 'webpack'
import * as path from "path"
import * as HtmlWebpackPlugin from 'html-webpack-plugin'
2019-07-19 18:00:51 +02:00
import * as express from 'express'
import * as WebpackDevServer from "webpack-dev-server"
import {httpSSRHandler} from "./SSR/handler"
2019-04-19 19:12:05 +02:00
const config: webpack.Configuration = {
entry: './App/index.tsx',
resolve: {
extensions: [".js", ".jsx", ".ts", ".tsx"]
},
2019-05-25 10:36:18 +02:00
devServer: {
historyApiFallback: true,
hot: true,
2019-07-19 18:00:51 +02:00
before: (app: express.Application, server: WebpackDevServer) => {
//todo: improve the regex
app.get(/^((?!\.\w+).)*$/, httpSSRHandler)
},
2019-05-25 10:54:49 +02:00
proxy: {
'/graphql': {
redirect: false,
changeOrigin: true,
target: `http://localhost:4000`,
2019-06-21 08:07:56 +02:00
},
'/api': {
redirect: false,
changeOrigin: true,
target: `http://localhost:4000`,
2019-05-25 10:54:49 +02:00
}
}
2019-05-25 10:36:18 +02:00
},
2019-04-19 19:12:05 +02:00
module: {
rules: [
{
exclude: path.resolve(__dirname, "node_modules"),
test: /\.tsx?$/,
use: {
loader: "babel-loader",
options: {
presets: [
"@babel/typescript",
"@babel/react"
],
plugins: [].filter(Boolean)
}
}
} ]
},
2019-05-25 10:54:49 +02:00
devtool: '@source-map',
2019-04-19 19:12:05 +02:00
output: {
path: path.resolve(__dirname, './dist'),
2019-06-05 14:21:43 +02:00
filename: 'bundle.js',
publicPath: '/'
2019-04-19 19:12:05 +02:00
},
plugins: [new HtmlWebpackPlugin({
title: "blabla",
})]
}
export default config