-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.babel.js
executable file
·65 lines (58 loc) · 1.66 KB
/
webpack.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
import path from 'path';
import {loaders} from './config/loaders';
import {plugins} from './config/common.config';
import {prodPlugins, prodLoaders} from './config/prod.config';
import UglifyJsPlugin from 'uglifyjs-webpack-plugin';
const ENV = process.env.NODE_ENV || 'development';
const resolvePath = (value) => path.resolve(__dirname, value);
if (ENV === 'development') {
var {devPlugins, devServerconfig, devLoaders} = require('./config/dev.config');
}
const envPlugins = ENV === 'development' ? devPlugins : prodPlugins;
const envLoaders = ENV === 'development' ? devLoaders : prodLoaders;
module.exports = {
entry: {
bundle: ['./src/index.tsx'],
},
output: {
path: resolvePath('./build'),
filename: '[name].js',
},
resolve: {
alias: {
src: resolvePath('src/'),
views: resolvePath('src/views/'),
components: resolvePath('src/components/'),
config: resolvePath('src/environment'),
core: resolvePath('src/core/'),
models: resolvePath('src/models/'),
services: resolvePath('src/services/'),
style: resolvePath('src/style/'),
util: resolvePath('src/util/'),
},
extensions: ['.js', '.json', '.ts', '.tsx', '.scss', '.sass'],
},
optimization: {
minimizer: [
new UglifyJsPlugin({
extractComments: true,
uglifyOptions: {
compress: {
reduce_vars: false,
inline: true,
},
},
}),
],
},
module: {
rules: loaders.concat(envLoaders),
},
plugins: plugins.concat(envPlugins),
stats: {
colors: true,
},
// devtool: 'source-map',
devtool: ENV !== 'production' && 'eval',
...devServerconfig,
};