-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-overrides.js
30 lines (25 loc) · 1.03 KB
/
config-overrides.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
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const path = require("path");
const webpack = require("webpack");
const dependencies = Object.keys(require("./package.json").dependencies || {});
const peerDependencies = Object.keys(require("./package.json").peerDependencies || {});
const libraryName = path.basename(process.env.npm_package_name);
const entryFile = "src/index.js";
const outputFile = `static/js/${path.basename(process.env.npm_package_main)}`;
const outputDir = "build";
module.exports = function override(config, env) {
config.entry = { [libraryName]: path.resolve(entryFile) };
config.output.library = libraryName;
config.output.libraryTarget = "umd";
config.output.filename = outputFile;
config.output.path = path.resolve(outputDir);
config.optimization = {};
config.externals = [...dependencies, ...peerDependencies];
config.plugins = [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new MiniCssExtractPlugin({
filename: "static/css/styles.css",
}),
];
return config;
};