-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
90 lines (87 loc) · 2.18 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
const path = require('path');
const glob = require('glob');
const TerserPlugin = require('terser-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const getPackageJson = require('./scripts/getPackageJson');
const { name, version } = getPackageJson();
const entry = glob.sync("./src/*/index.+(js|jsx|ts|tsx)")
.reduce((x, y) => {
const key = y.split('/')[2];
return Object.assign(x, {
[key]: y
});
}, {});
module.exports = {
mode: "production",
entry,
devtool: 'source-map',
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build'),
libraryTarget: 'var',
library: 'PRSSComponent'
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
/**
* Dependencies are disclosed in a LICENSE file
*/
extractComments: {
condition: /^\**!|@preserve|@license|@cc_on/i,
filename: (file, fileData) => {
return file.replace(/\.(\w+)($|\?)/, '.$1.LICENSE.txt$2');
},
banner: (licenseFile) => {
return `License information can be found in https://cdn.jsdelivr.net/npm/${name}@${version}/build/${licenseFile}`;
},
},
}),
new OptimizeCSSAssetsPlugin({
cssProcessorPluginOptions: {
preset: ['default', { discardComments: { removeAll: true } }],
}
})
],
},
module: {
rules: [
{
test: /\.m?js(x?)|ts(x?)$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader'
},
},
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader"
],
},
{
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/,
use: ['url-loader'],
}
]
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
performance: {
hints: false
},
externals: {
"prss": "PRSS",
"react": "React",
"react-dom": "ReactDOM"
},
plugins: [
new MiniCssExtractPlugin({
filename: `[name].css`
}),
]
};