forked from asmyshlyaev177/react-horizontal-scrolling-menu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
82 lines (79 loc) · 1.92 KB
/
webpack.config.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
/* eslint-disable no-undef */
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const outputPath = path.resolve(__dirname, 'build');
const filename = 'index';
const options = env => ({
module: {
rules: [
{
test: /\.(jsx?|jsm)$/,
include: path.resolve(__dirname, 'src'),
exclude: /(node_modules|bower_components|build)/,
use: {
loader: 'babel-loader',
options: {
sourceMaps: env.development ? 'both' : undefined,
},
},
},
{
test: /\.(tsx?)$/,
include: path.resolve(__dirname, 'src'),
exclude: /(node_modules|bower_components|build)/,
use: [
{
loader: 'babel-loader',
options: {
sourceMaps: env.development ? 'both' : undefined,
},
},
{
loader: 'ts-loader',
}
],
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
alias: {
'react-dom$': 'react-dom/profiling',
'scheduler/tracing': 'scheduler/tracing-profiling',
}
},
externals: {
react: {
root: 'React',
commonjs2: 'react',
},
},
optimization: {
minimizer: [
new UglifyJsPlugin({
test: /\.js($|\?)/i,
uglifyOptions: {
output: { beautify: false },
safari10: true,
webkit: true,
drop_console: true,
passes: 5,
},
}),
],
},
});
module.exports = env => {
return [
{
devtool: env.development ? 'source-map' : 'none',
entry: './src/index.ts',
output: {
path: outputPath,
filename: `${filename}.js`,
libraryTarget: 'commonjs2', // THIS IS THE MOST IMPORTANT LINE! :mindblow: I wasted more than 2 days until realize this was the line most important in all this guide.
},
...options(env),
}
];
};