This repository has been archived by the owner on Jun 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
webpack.config.prod.js
108 lines (106 loc) · 3.1 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
const webpack = require('webpack');
const path = require('path');
const HtmlwebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const ManifestPlugin = require('webpack-manifest-plugin');
const ROOT_PATH = path.resolve(__dirname);
module.exports = {
devtool: 'source-map',
entry: {
main: [
'./src/client/index.tsx'
],
vendor: [
'react',
'react-dom',
'styled-components',
'react-redux',
'react-router',
'react-router-redux',
'react-markdown',
'redux-connect',
'redux',
'rxjs',
'axios',
'redux-logic',
'react-apollo',
'graphql-tag',
'apollo-client',
]
},
output: {
path: path.resolve(ROOT_PATH, './build/public'),
publicPath: '/',
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].chunk.js',
},
stats: {
chunks: true,
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
alias: {
components: path.resolve(ROOT_PATH, 'src/client/components'),
features: path.resolve(ROOT_PATH, 'src/client/features'),
shared: path.resolve(ROOT_PATH, 'src/client/shared'),
ui: path.resolve(ROOT_PATH, 'packages/ui/src'),
test: path.resolve(ROOT_PATH, 'src/client/test'),
root: path.resolve(ROOT_PATH, 'src/client/'),
},
},
module: {
loaders: [
{ test: /\.tsx?$/, loaders: ['babel-loader', 'ts-loader'], include: [path.join(__dirname, 'src'), path.resolve(__dirname, 'packages')] },
{ test: /\.jsx?$/, exclude: /node_modules/, loaders: ['babel-loader'], include: path.join(__dirname, 'src') },
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader!postcss-loader'
}),
},
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.md$/, loader: 'html!markdown-loader' },
]
},
plugins: [
new ManifestPlugin({
fileName: 'manifest.json',
basePath: '/'
}),
new ExtractTextPlugin('[name].[contenthash].css'),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
children: true,
minChunks: 2,
async: true,
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
'process.env.API_URL': JSON.stringify(process.env.API_URL || 'http://localhost:1338/api'),
}),
new webpack.optimize.OccurrenceOrderPlugin(true),
new webpack.optimize.UglifyJsPlugin({
sourceMap: false
}),
new webpack.LoaderOptionsPlugin({
debug: false,
minimize: true,
debug: false,
options: {
/**
* Legacy postCSS config
* @reference https://github.com/azat-io/webpack2-css-modules-demo/blob/master/scripts/webpack.config.babel.js
*/
postcss: function () {
return {
defaults: [precss, autoprefixer],
cleaner: [autoprefixer({ browsers: [] })]
};
},
}
}),
]
};