forked from eile/hiking-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.prod.js
112 lines (107 loc) · 2.52 KB
/
webpack.config.prod.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
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const extractSass = new ExtractTextPlugin({
filename: "[name].css",
disable: false
});
const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
const path = require('path');
module.exports = {
entry: {
main: [
'./src/ts/main.ts'
]
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].bundle.js',
libraryTarget: 'amd'
},
module: {
loaders:[
{
test: /\.json$/,
loader: 'json-loader'
}
],
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /(node_modules)/,
use: {
loader: 'awesome-typescript-loader'
}
},
{
// Capture eot, ttf, woff, and woff2
test: /\.(eot|ttf|woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: "file-loader",
options: {
outputPath: 'fonts/'
// useRelativePath: true
}
},
},
{
test: /\.scss$/,
use: extractSass.extract({
use: [{
loader: "css-loader"
}, {
loader: "sass-loader"
}],
// use style-loader in development
fallback: "style-loader"
})
},
{
test: /\.(jpe?g|png|gif|svg)$/,
loader: "url-loader",
options: {
limit: 10 * 1024
}
},
{
test: /\.(jpe?g|png|gif|svg)$/,
loader: "image-webpack-loader",
enforce: "pre"
}
]
},
resolve: {
extensions: ['.ts', '.js', '.json']
},
plugins: [
extractSass,
new ServiceWorkerWebpackPlugin({
entry: path.join(__dirname, 'src/ts/sw.ts'),
filename: '../sw.js',
publicPath: '/hiking-app/dist/'
}),
new UglifyJsPlugin()
/* new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity
}) */
],
devServer: {
contentBase: __dirname
},
externals: [
function (context, request, callback) {
// exclude any esri or dojo modules from the bundle
// these are included in the ArcGIS API for JavaScript
// and its Dojo loader will pull them from its own build output
if (/^dojo/.test(request) ||
/^dojox/.test(request) ||
/^dijit/.test(request) ||
/^esri/.test(request)
) {
return callback(null, 'amd ' + request);
}
callback();
}
]
}