forked from react-ui-org/react-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
100 lines (97 loc) · 2.37 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
const path = require('path');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const VisualizerPlugin = require('webpack-visualizer-plugin');
const MAX_DEVELOPMENT_OUTPUT_SIZE = 2900000;
const MAX_PRODUCTION_OUTPUT_SIZE = 330000;
module.exports = (env, argv) => ({
devtool: argv.mode === 'production'
? false
: 'eval-cheap-module-source-map',
entry: {
lib: [
path.join(__dirname, 'src/lib/index.js'),
],
},
externals: {
react: {
amd: 'react',
commonjs: 'react',
commonjs2: 'react',
root: 'React',
umd: 'react',
},
'react-dom': {
amd: 'react-dom',
commonjs: 'react-dom',
commonjs2: 'react-dom',
root: 'ReactDOM',
umd: 'react-dom',
},
},
module: {
rules: [
{
include: path.join(__dirname, 'src/lib'),
test: /\.(js|jsx)$/,
use: [{ loader: 'babel-loader' }],
},
{
test: /\.scss$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
modules: {
localIdentName: argv.mode === 'production'
? '[hash:base64:8]'
: '[name]__[local]__[hash:base64:8]',
},
},
},
{ loader: 'postcss-loader' },
{
loader: 'sass-loader',
options: {
sassOptions: {
includePaths: ['node_modules'],
},
},
},
],
},
],
},
output: {
filename: argv.mode === 'production'
? '[name].js'
: '[name].development.js',
libraryTarget: 'umd',
path: path.join(__dirname, 'dist'),
publicPath: '/dist/',
},
performance: {
hints: 'error',
maxAssetSize: argv.mode === 'production'
? MAX_PRODUCTION_OUTPUT_SIZE
: MAX_DEVELOPMENT_OUTPUT_SIZE,
maxEntrypointSize: argv.mode === 'production'
? MAX_PRODUCTION_OUTPUT_SIZE
: MAX_DEVELOPMENT_OUTPUT_SIZE,
},
plugins: [
new StyleLintPlugin({
configFile: 'stylelint.config.js',
files: '**/*.scss',
}),
new VisualizerPlugin({
filename: argv.mode === 'production'
? '../lib-stats.html'
: '../lib-stats.development.html',
}),
],
resolve: {
extensions: ['.js', '.jsx', '.scss'],
modules: ['src/lib', 'node_modules'],
},
});