forked from jsakas/figma-plugin-color-import-export
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
88 lines (77 loc) · 2.44 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
const HtmlWebpackPlugin = require('html-webpack-plugin')
const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin')
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const SentryCliPlugin = require('@sentry/webpack-plugin');
const { DefinePlugin } = require('webpack')
const PackageJSON = require('./package.json');
const path = require('path')
const {
SENTRY_ORG,
SENTRY_PROJECT,
SENTRY_AUTH_TOKEN,
} = process.env
module.exports = (env, argv) => {
const GA_ENABLED = argv.mode === 'production' ? true : false
const SENTRY_ENABLED = argv.mode === 'production' ? true : false
return {
mode: argv.mode === 'production' ? 'production' : 'development',
devtool: argv.mode === 'production' ? 'source-map' : 'inline-source-map',
entry: {
ui: './src/app/index.tsx',
code: './src/plugin/controller.ts',
},
module: {
rules: [
{ test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/ },
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
{ test: /\.(png|jpg|gif|webp|svg)$/, use: 'url-loader' },
{ test: /\.hbs$/i, use: 'raw-loader' },
],
},
resolve: {
plugins: [
new TsconfigPathsPlugin(),
],
extensions: ['.tsx', '.ts', '.jsx', '.js'],
alias: {
'@mui/material': '@mui/joy',
'react': path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom'),
'handlebars': path.resolve('./node_modules/handlebars/dist/handlebars.min.js'),
}
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
},
plugins: [
SENTRY_ENABLED &&
SENTRY_ORG &&
SENTRY_PROJECT &&
SENTRY_AUTH_TOKEN &&
new SentryCliPlugin({
include: 'dist',
ignore: ['node_modules'],
release: PackageJSON.version,
configFile: '.sentryclirc',
}),
new DefinePlugin({
'SENTRY_ENABLED': GA_ENABLED,
'GA_ENABLED': SENTRY_ENABLED,
'PACKAGE_VERSION': JSON.stringify(PackageJSON.version),
}),
new HtmlWebpackPlugin({
template: './src/app/index.ejs',
filename: 'ui.html',
chunks: ['ui'],
cache: false,
title: 'Color Import / Export',
global: {
SENTRY_ENABLED,
GA_ENABLED
}
}),
new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/ui/]),
].filter(Boolean),
}
}