This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
128 lines (125 loc) · 2.39 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
const webpack = require("webpack");
const path = require("path");
const process = require("process");
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HandlebarsPlugin = require('handlebars-webpack-plugin');
const nib = require('nib');
const vendors = require('./webpack.vendors');
let extHost = process.env.HOST;
const host = '0.0.0.0';
const port = 3000;
module.exports = {
entry: {
client: ['./src/ts/lib/client.tsx'],
vendor: vendors
},
output: {
path: path.resolve(__dirname, './dist/webroot/'),
filename: 'js/[name].js',
publicPath: '/'
},
devtool: "source-map",
devServer: {
contentBase: [
path.join(__dirname, "dist"),
path.join(__dirname, "dist/webroot")
],
hot:true,
overlay: {
warnings: true,
errors: true
},
historyApiFallback: true,
host: host,
port: port
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".json"]
},
module: {
rules: [
{
test: /\.tsx?$/,
use: ['awesome-typescript-loader']
}, {
test: /\.styl$/,
use: [
{
loader: "style-loader",
options: {
sourceMap: true,
}
},
{
loader: 'css-loader',
options: {
sourceMap: true,
minimize: true
}
}, {
loader: 'stylus-loader',
options: {
sourceMap: true,
use: [
nib()
]
}
}
]
},
{
enforce: "pre",
test:
/\.js$/,
loader:
"source-map-loader"
},
{
test: /\.(woff|ttf|eot)(\?v=[a-z0-9]\.[a-z0-9]\.[a-z0-9])?$/,
loaders:
['file-loader']
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
loaders:
[
{
loader: 'file-loader',
query: {
context: './src',
name: '[path][name].[ext]'
}
}
]
}
]
},
plugins: [
new CleanWebpackPlugin(['dist/webroot'], {
verbose: true
}),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new CopyWebpackPlugin([
{
from: 'src/webroot',
to: __dirname + '/dist/webroot'
}, {
from: 'src/ts/app/api/local-data',
to: __dirname + '/dist/webroot/local-data'
}
], {
debug: false,
copyUnmodified: false
}),
new HandlebarsPlugin({
entry: './src/hbs/develop.hbs',
output: './dist/index.html',
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity
})
]
};