-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
100 lines (98 loc) · 2.8 KB
/
Copy pathwebpack.config.js
File metadata and controls
100 lines (98 loc) · 2.8 KB
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
const path = require('path')
const resolve = require('path').resolve
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
module.exports = {
devtool: 'inline-source-map',
entry: {
'app': [
'babel-polyfill',
'react-hot-loader/patch',
'./index.tsx'
]
},
output: {
path: path.join(__dirname, '/dist/'),
filename: 'bundle.js',
publicPath: '/dist/'
},
resolve: {
extensions: [ '.ts', '.tsx', '.js', '.json', '.scss', '.css'],
modules: ['node_modules'],
alias: {
'_ducks': resolve(__dirname, 'src/ducks/*'),
'_pages': resolve(__dirname, 'src/view/pages'),
'_decorators': resolve(__dirname, 'src/view/decorators'),
'_components': resolve(__dirname, 'src/view/components'),
'_sections': resolve(__dirname, 'src/view/sections'),
}
},
devServer: {
hot: true,
inline: true,
contentBase: path.join(__dirname, 'public'),
// match the output path
historyApiFallback: true,
publicPath: '/dist/'
// match the output `publicPath`
},
context: path.join(__dirname, 'src'),
module: {
loaders: [
{
test: /\.js?$/,
exclude: /node_modules/,
use: [
'babel-loader',
]
}, {
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
loader: 'react-hot-loader/webpack!awesome-typescript-loader',
}, {
test: /\.sass$/,
loader: 'style-loader!css-loader!sass-loader'
}, {
test: /\.(png|jpe?g|svg)$/,
// include: [path.join(__dirname, 'src/img'), path.join(__dirname, 'src/view/Chat')],
loader: 'file-loader?name=public/[name].[ext]'
}, {
test: /\.(ttf|eot|svg|woff(2)?)$/,
include: [path.join(__dirname, 'src/assets/fonts')],
loader: 'file-loader?name=public/[name].[ext]'
}
]
},
plugins: [
new ExtractTextPlugin('./main.css'),
new webpack.NamedModulesPlugin(),
// new webpack.optimize.UglifyJsPlugin({
// beautify: false,
// comments: true,
// minimize: true,
// compress: {
// sequences : true,
// booleans : true,
// loops : true,
// unused : true,
// warnings : false,
// drop_console: true,
// unsafe : true
// }
// }),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.min\.css$/,
cssProcessorOptions: { discardComments: { removeAll: true } }
}),
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.html$/,
threshold: 10240,
minRatio: 0.8
})
],
watch: true
}