-
Notifications
You must be signed in to change notification settings - Fork 64
/
webpack.config.build.js
106 lines (105 loc) Β· 2.69 KB
/
webpack.config.build.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
const webpack = require('webpack')
const cssnano = require('cssnano')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: {
app: ['whatwg-fetch', './src'],
css: 'tachyons',
},
output: {
path: './dist',
filename: '[name].[hash].js',
publicPath: '/',
},
module: {
rules: [{
enforce: 'pre',
test: /\.ts(x?)$/,
loader: 'tslint-loader',
exclude: /node_modules/,
}, {
test: /module\.styl/,
loader: 'style-loader!css-loader?modules!postcss-loader!stylus-loader',
}, {
test: /module\.css/,
loader: 'style-loader!css-loader?modules!postcss-loader',
}, {
test: /\.css/,
exclude: /module\.css/,
loader: 'style-loader!css-loader!postcss-loader',
}, {
test: /\.ts(x?)$/,
exclude: /node_modules/,
loader: 'babel-loader!awesome-typescript-loader',
}, {
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
}, {
test: /\.json/,
loader: 'json-loader',
}, {
test: /\.(jpg|png)/,
loader: 'file-loader',
}, {
test: /content\/.*\.svg$/,
loader: 'file-loader',
}, {
test: /icons\/.*\.svg$/,
loader: 'raw-loader!svgo-loader?{"plugins":[{"removeStyleElement":true}]}',
}, {
test: /\.md/,
loader: 'raw-loader',
}],
},
plugins: [
new webpack.DefinePlugin({
__LAST_UPDATE__: '"' + new Date().toLocaleDateString() + '"',
__GA_TRACKING_CODE__: '"UA-74131346-6"',
__GITHUB_OAUTH_CLIENT_ID__: JSON.stringify(process.env.GITHUB_OAUTH_CLIENT_ID.toString()),
__LAMBDA_AUTH__: '"https://learnx.graph.cool/prod/learnapollo"',
__LAMBDA_DOWNLOAD_EXAMPLE__: '"https://dynamic-resources.graph.cool"',
'process.env': {
'NODE_ENV': JSON.stringify('production')
},
}),
new HtmlWebpackPlugin({
favicon: 'static/favicon.png',
template: 'src/index.html',
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
unused: true,
dead_code: true,
warnings: false,
}
}),
new webpack.LoaderOptionsPlugin({
options: {
postcss: [
cssnano({
autoprefixer: {
add: true,
remove: true,
browsers: ['last 2 versions'],
},
discardComments: {
removeAll: true,
},
safe: true,
})
],
svgo: {
plugins: [
{removeStyleElement: true},
],
},
}
}),
],
resolve: {
extensions: ['.js', '.ts', '.tsx'],
}
}