-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
111 lines (105 loc) · 2.49 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const path = require('path');
// Polyfill all the node stuff
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const packageJson = require('./package.json');
const analyseBundle = process.env.ANALYSE === 'true';
const bundleName = `main-${packageJson.version}`;
if (!bundleName) {
throw new Error('Bundle name/version is not set');
}
module.exports = {
devtool: 'source-map',
mode: 'production',
entry: {
Marinade: {
import: './src/library.tsx',
filename: `${bundleName}.js`,
},
Tailwind: {
import: './src/styles/globals.css',
},
MarinadeRenderer: {
dependOn: 'Marinade',
import: './src/index.tsx',
filename: `${bundleName}-app.js`,
},
},
cache: {
type: 'filesystem',
},
module: {
rules: [
// Tailwind support
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'],
},
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
// To compile for client
compilerOptions: {
jsx: 'react-jsx',
},
},
},
],
exclude: /node_modules/,
},
{
test: /\.svg$/,
loader: 'svg-inline-loader',
},
// Some libs are module based
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
],
},
plugins: (() => {
const plugins = [
new NodePolyfillPlugin(),
new MiniCssExtractPlugin({
filename: `${bundleName}-[name].css`,
}),
];
if (analyseBundle) {
plugins.push(new BundleAnalyzerPlugin());
}
return plugins;
})(),
resolve: {
extensions: ['.tsx', '.ts', '.js'],
fallback: {
fs: false,
},
alias: {
src: path.resolve(__dirname, 'src'),
public: path.resolve(__dirname, 'public'),
'./../tokens/solana.tokenlist.json': false,
},
},
target: 'web',
output: {
library: '[name]',
libraryTarget: 'window',
path: path.resolve(__dirname, 'public'),
publicPath: '/public/',
},
optimization: {
minimizer: [
'...', // Include existing minimizer.
new CssMinimizerPlugin(),
],
minimize: true,
},
};