-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
108 lines (98 loc) · 2.96 KB
/
webpack.config.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// REQUIRE
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var nodeExternals = require('webpack-node-externals');
// PRE-CONFIG
var BUILD_DIR = path.resolve(__dirname, 'dev');
var APP_DIR = path.resolve(__dirname, 'src/client');
var SERVER_DIR = path.resolve(__dirname, 'src/server');
var config = [
//////////////////////////////////////////////
// WEBPACK CLIENT BUILD
//////////////////////////////////////////////
{
entry: [
APP_DIR + '/app/app.tsx'
],
output: {
path: BUILD_DIR + '/public',
filename: 'bundle.js'
},
// Enable sourcemaps for debugging webpack's output.
devtool: "source-map",
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ["", ".webpack.js", ".web.js", ".ts", ".tsx", ".jsx", ".js", ".html"]
},
module: {
loaders: [
{
test: /\.tsx?$/,
loader: "ts-loader"
},
//{
// test : /\.jsx?/,
// include : APP_DIR,
// loader : 'babel'
//},
{
test: /\.html$/,
loader: "raw-loader"
}
],
preLoaders: [
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{test: /\.jsx$/, loader: "source-map-loader"}
]
},
plugins: [
new HtmlWebpackPlugin({
title: 'RealTimeDashboard',
filename: 'index.html',
template: APP_DIR + '/index.html'
})
]
},
//////////////////////////////////////////////
// WEBPACK SERVER BUILD
//////////////////////////////////////////////
{
//entry: SERVER_DIR + '/server.js',
entry: [
SERVER_DIR + '/server.js'
],
target: 'node',
node: {
__dirname: false,
__filename: false,
},
output: {
path: BUILD_DIR,
filename: 'server.js'
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ["", ".webpack.js", ".web.js", ".ts", ".tsx", ".jsx", ".js", ".html"]
},
module: {
loaders: [
{
test : /\.js?/,
include : SERVER_DIR,
loader : 'babel'
},
//{
// test : /\.js?/,
// include : SERVER_DIR,
// loader : 'node'
//},
{
test: /\.html$/,
loader: "raw-loader"
}
]
},
externals: [nodeExternals()]
}];
module.exports = config;