mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-01-06 13:15:24 +08:00
86 lines
2.3 KiB
JavaScript
86 lines
2.3 KiB
JavaScript
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const { ModuleFederationPlugin } = require('webpack').container;
|
|
const webpack = require('webpack');
|
|
const path = require('path');
|
|
|
|
const deps = require('./package.json').dependencies;
|
|
|
|
module.exports = {
|
|
entry: './src/index',
|
|
output: {
|
|
path: path.resolve(__dirname, 'dist'),
|
|
},
|
|
// webpack 5 support polyfills
|
|
resolve: {
|
|
alias: {
|
|
buffer: require.resolve('buffer'),
|
|
},
|
|
fallback: { buffer: false },
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /bootstrap\.js$/,
|
|
loader: 'bundle-loader',
|
|
options: {
|
|
lazy: true,
|
|
},
|
|
},
|
|
// TODO: FIXME: do NOT webpack 5 support with this
|
|
// x-ref: https://github.com/webpack/webpack/issues/11467
|
|
// waiting for babel fix: https://github.com/vercel/next.js/pull/17095#issuecomment-692435147
|
|
{
|
|
test: /\.m?js/,
|
|
resolve: {
|
|
fullySpecified: false,
|
|
},
|
|
},
|
|
{
|
|
test: /\.jsx?$/,
|
|
loader: 'babel-loader',
|
|
exclude: /node_modules/,
|
|
options: {
|
|
presets: ['@babel/preset-react'],
|
|
},
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
use: [
|
|
{
|
|
loader: 'style-loader',
|
|
},
|
|
{
|
|
loader: 'css-loader', // translates CSS into CommonJS
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
new ModuleFederationPlugin({
|
|
name: 'lowdefy_renderer',
|
|
library: { type: 'var', name: 'lowdefy_renderer' },
|
|
filename: 'remoteEntry.js',
|
|
exposes: {
|
|
'./Renderer': './src/Renderer',
|
|
},
|
|
shared: {
|
|
...deps,
|
|
react: {
|
|
import: 'react', // the "react" package will be used a provided and fallback module
|
|
shareKey: 'react', // under this name the shared module will be placed in the share scope
|
|
shareScope: 'default', // share scope with this name will be used
|
|
singleton: true, // only a single version of the shared module is allowed
|
|
},
|
|
'react-dom': {
|
|
singleton: true, // only a single version of the shared module is allowed
|
|
},
|
|
},
|
|
}),
|
|
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
|
|
new HtmlWebpackPlugin({
|
|
template: './public/index.html',
|
|
}),
|
|
],
|
|
};
|