first commit
This commit is contained in:
78
webpack.config.js
Normal file
78
webpack.config.js
Normal file
@@ -0,0 +1,78 @@
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin')
|
||||
const Dotenv = require('dotenv-webpack')
|
||||
const path = require('path')
|
||||
|
||||
module.exports = (env, argv) => ({
|
||||
mode: argv.mode === 'production' ? 'production' : 'development',
|
||||
|
||||
// This is necessary because Figma's 'eval' works differently than normal eval
|
||||
devtool: argv.mode === 'production' ? false : 'inline-source-map',
|
||||
|
||||
entry: {
|
||||
ui: './src/ui.tsx', // The entry point for your UI code
|
||||
code: './src/code.ts', // The entry point for your plugin code
|
||||
},
|
||||
performance: {
|
||||
hints: false, // 完全禁用警告
|
||||
// 或者调整限制
|
||||
maxEntrypointSize: 700000, // 增加入口点大小限制到 700KB
|
||||
maxAssetSize: 700000, // 增加资源大小限制到 700KB
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
// Converts TypeScript code to JavaScript
|
||||
{ test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/ },
|
||||
|
||||
// Enables including CSS by doing "import './file.css'" in your TypeScript code
|
||||
{ test: /\.css$/, use: ['style-loader', { loader: 'css-loader' }] },
|
||||
|
||||
// Allows you to use "<%= require('./file.svg') %>" in your HTML code to get a data URI
|
||||
{ test: /\.(png|jpg|gif|webp|svg|zip)$/, loader: 'url-loader' },
|
||||
|
||||
// 添加 wasm 文件的处理规则
|
||||
{
|
||||
test: /\.wasm$/,
|
||||
type: 'asset/resource',
|
||||
generator: {
|
||||
filename: '[name][ext]'
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
// Webpack tries these extensions for you if you omit the extension like "import './file'"
|
||||
resolve: {
|
||||
extensions: ['.tsx', '.ts', '.jsx', '.js'],
|
||||
fallback: {
|
||||
fs: false,
|
||||
path: false,
|
||||
crypto: false,
|
||||
}
|
||||
},
|
||||
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
path: path.resolve(__dirname, 'dist'), // Compile into a folder called "dist"
|
||||
publicPath: '/',
|
||||
crossOriginLoading: 'anonymous'
|
||||
},
|
||||
|
||||
// Tells Webpack to generate "ui.html" and to inline "ui.ts" into it
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
template: './src/ui.html',
|
||||
filename: 'ui.html',
|
||||
inlineSource: '.(js)$',
|
||||
chunks: ['ui'],
|
||||
}),
|
||||
new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/ui/]),
|
||||
new Dotenv({
|
||||
defaults: false, // 首先加载默认值
|
||||
path: '.env', // 默认的 .env 文件
|
||||
safe: false,
|
||||
systemvars: false,
|
||||
}),
|
||||
],
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user