Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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