forked from openmrs/openmrs-esm-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
73 lines (71 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
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const SystemJSPublicPathWebpackPlugin = require("systemjs-webpack-interop/SystemJSPublicPathWebpackPlugin");
const { resolve } = require("path");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const { peerDependencies } = require("./package.json");
module.exports = (env) => ({
entry: [
resolve(__dirname, "src/index.ts"),
resolve(__dirname, "src/_all.scss"),
],
output: {
libraryTarget: "system",
filename: "openmrs-esm-styleguide.js",
chunkFilename: "[name].js",
path: resolve(__dirname, "dist"),
},
mode: "production",
devtool: "source-map",
module: {
rules: [
{
test: /\.s?[ac]ss$/i,
use: [
{ loader: MiniCssExtractPlugin.loader },
"css-loader",
{ loader: require.resolve("postcss-loader") },
"sass-loader",
],
},
{
test: /\.(js|jsx|ts|tsx)$/,
use: ["babel-loader"],
},
{
test: /\.(woff|woff2|png)?$/,
type: "asset/resource",
},
{
test: /\.(svg|html)$/,
type: "asset/source",
},
],
},
devServer: {
disableHostCheck: true,
headers: {
"Access-Control-Allow-Origin": "*",
},
},
externals: Object.keys(peerDependencies || {}),
resolve: {
modules: ["node_modules"],
extensions: [".js", ".jsx", ".json", ".ts", ".tsx"],
},
optimization: {
minimize: true,
minimizer: [new CssMinimizerPlugin(), "..."],
},
plugins: [
new SystemJSPublicPathWebpackPlugin(),
new CleanWebpackPlugin(),
new MiniCssExtractPlugin({
filename: "openmrs-esm-styleguide.css",
}),
new BundleAnalyzerPlugin({
analyzerMode: env && env.analyze ? "static" : "disabled",
}),
],
});