Skip to content

Instantly share code, notes, and snippets.

@crutchcorn
Created February 15, 2022 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crutchcorn/b84e6ea3425b719e13d7df0aba8e0273 to your computer and use it in GitHub Desktop.
Save crutchcorn/b84e6ea3425b719e13d7df0aba8e0273 to your computer and use it in GitHub Desktop.
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const BundleAnalyzerPlugin =
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const root = path.resolve(__dirname, "./");
module.exports = {
name: "seaside-react",
entry: "./src/index.tsx",
externals: {
react: {
root: "React",
commonjs2: "react",
commonjs: "react",
amd: "react",
umd: "react",
},
"prop-types": {
root: "PropTypes",
commonjs: "prop-types",
commonjs2: "prop-types",
},
"react-dom": {
root: "ReactDOM",
commonjs2: "react-dom",
commonjs: "react-dom",
amd: "react-dom",
umd: "react-dom",
},
"react-dom/server": {
root: "ReactDOMServer",
commonjs: "react-dom/server",
commonjs2: "react-dom/server",
},
},
module: {
noParse: [
require.resolve("react"),
require.resolve("prop-types"),
require.resolve("react-dom"),
require.resolve("react-dom/server"),
],
rules: [
{
test: /\.(ts|tsx|js|jsx)?$/,
include: [
path.resolve(root, "index.web.js"),
path.resolve(root, "src"),
path.resolve(root, "../../node_modules/react-native-uncompiled"),
path.resolve(root, "../../node_modules/react-native-dynamic"),
path.resolve(root, "../../node_modules/react-native-vector-icons"),
path.resolve(root, "../tokens"),
],
use: [
{
loader: "babel-loader",
options: {
babelrc: false,
configFile: false,
cacheDirectory: true,
presets: ["@babel/preset-react", "@babel/preset-typescript"],
plugins: [["react-native-web"]],
},
},
],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
// alias: {
// "react-native$": "react-native-web",
// },
},
output: {
filename: "react.js",
path: path.resolve(__dirname, "dist"),
libraryTarget: "commonjs",
},
plugins: [new BundleAnalyzerPlugin()],
};
module.exports.parallelism = 3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment