-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.production.config.babel.js
119 lines (116 loc) · 4 KB
/
webpack.production.config.babel.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
'use strict';
import {DefinePlugin, NamedModulesPlugin, NoEmitOnErrorsPlugin} from 'webpack';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import FaviconsWebpackPlugin from 'favicons-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import OptimizeCssAssetsPlugin from 'optimize-css-assets-webpack-plugin';
import UglifyJsPlugin from 'uglifyjs-webpack-plugin';
import path from 'path';
export default {
devtool: 'cheap-module-source-map',
entry: [
path.resolve(__dirname, 'src/less/main.less'),
path.resolve(__dirname, 'src/index.jsx')
],
output: {
path: path.resolve(__dirname, 'dist/'),
filename: '[name].js',
publicPath: '/'
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.tpl.html',
inject: 'body',
filename: 'index.html',
hash: true
}),
new NoEmitOnErrorsPlugin(),
new NamedModulesPlugin(),
new DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new ExtractTextPlugin('styles.min.css'),
new OptimizeCssAssetsPlugin(),
new FaviconsWebpackPlugin('images/favicon.png'),
new UglifyJsPlugin()
],
module: {
rules: [
{
test: /\.jsx?$/, use: ['source-map-loader'], enforce: 'pre'
},
{
test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/, include: __dirname
},
{
test: /\.less$/, use: [{
loader: 'style-loader'
}, {
loader: 'css-loader',
options: {
sourceMap: true,
importLoaders: 2
}
}, {
loader: 'postcss-loader',
options: {
sourceMap: true
}
}, {
loader: 'less-loader',
options: {
sourceMap: true
}
}]
}, {
test: /\.(png|jpe?g|gif|svg)$/,
exclude: /icons/,
use: [{
loader: 'file-loader',
options: {
name: 'images/[name]---[hash:base64:5].[ext]'
}
}]
}, {
test: /\.svg$/,
include: /icons/,
use: [{
loader: 'babel-loader'
}, {
loader: 'react-svg-loader',
query: {
jsx: true,
svgo: {
plugins: [{
removeStyleElement: true,
cleanupAttrs: true,
cleanupIDs: true,
mergePaths: true,
removeUselessStrokeAndFill: true,
removeUnusedNS: true,
cleanupNumericValues: true
}],
floatPrecision: 2,
pretty: true
}
}
}]
},
{test: /.(woff|woff2|eot|ttf|otf)$/, use: ['file-loader']},
{test: /\.csv$/, loader: 'raw-loader'}
]
},
resolve: {
modules: [path.resolve(__dirname, './src'), 'node_modules'],
descriptionFiles: ['package.json'],
mainFiles: ['index'],
extensions: ['.js', '.jsx'],
enforceExtension: false,
alias: {
styleGlobals: path.resolve(__dirname, 'src/styles/styleGlobals'),
ConfiguredRadium: path.resolve(__dirname, 'src/styles/ConfiguredRadium'),
ConfiguredAxios: path.resolve(__dirname, 'src/api/ConfiguredAxios')
}
},
target: 'web'
};