-
Notifications
You must be signed in to change notification settings - Fork 269
/
webpack.config.js
69 lines (68 loc) · 1.86 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
const path = require('path')
const webpack = require('webpack')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
module.exports = {
devtool: 'source-map',
entry: { 'react-dropdown-tree-select': './src/index.js' },
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
libraryTarget: 'umd',
library: 'ReactDropdownTreeSelect',
umdNamedDefine: true,
globalObject: 'this',
},
externals: {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
},
},
plugins: [
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'styles.css',
chunkFilename: '[id].css',
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
generateStatsFile: true,
}),
new CopyPlugin({ patterns: [{ from: path.join(__dirname, 'types'), to: path.join(__dirname, 'dist') }] }),
],
module: {
rules: [
{
test: /\.js$/,
use: ['babel-loader'],
include: path.join(__dirname, 'src'),
exclude: /node_modules/,
},
{
test: /\.css$/,
include: /src/,
exclude: /node_modules/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
localIdentName: 'react-dropdown-tree-select__[local]--[hash:base64:5]',
importLoaders: 1,
minimize: true,
sourceMap: true,
},
},
{ loader: 'postcss-loader' },
],
},
],
},
}