forked from nftblackmagic/web3cdn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcraco.config.js
58 lines (53 loc) · 1.83 KB
/
craco.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
const rewireBabelLoader = require("craco-babel-loader");
const { realpathSync } = require("fs");
const { resolve } = require("path");
const Dotenv = require("dotenv-webpack");
function forceAbsolutePackage(relativePath) {
const appDirectory = realpathSync(process.cwd());
return resolve(appDirectory, relativePath);
}
module.exports = {
babel: {
plugins: [["@babel/plugin-proposal-decorators", { legacy: true }]],
},
plugins: [
//This is a craco plugin: https://github.com/sharegate/craco/blob/master/packages/craco/README.md#configuration-overview
{
plugin: rewireBabelLoader,
options: {
includes: [
// On force un absolute path car c'est requis par babel-loader
forceAbsolutePackage("node_modules/@wagmi/core/dist"),
forceAbsolutePackage("node_modules/wagmi/dist"),
],
},
},
],
webpack: {
alias: {},
configure: (webpackConfig, { env, paths }) => {
webpackConfig.plugins.push(
new Dotenv({ systemvars: true, path: "./.env" })
);
// console.log("webpackConfig", env);
const isEnvProduction = env === "production";
const isEnvDevelopment = env === "development";
webpackConfig.output.libraryTarget = "umd";
webpackConfig.output.library = "NFTComponents";
webpackConfig.output.publicPath = "";
webpackConfig.output.filename = isEnvProduction
? "[name].js"
: isEnvDevelopment && "bundle.js";
// Turn off chunking
webpackConfig.optimization = {};
const miniCssPlugin = webpackConfig.plugins.find(
({ constructor }) => constructor.name === "MiniCssExtractPlugin"
);
if (miniCssPlugin) {
miniCssPlugin.options.filename = "[name].css";
miniCssPlugin.options.chunkFilename = "[name].css";
}
return webpackConfig;
},
},
};