Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
emma-sg committed Jan 4, 2024
1 parent 172c189 commit a1035bc
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 43 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"types": "./dist/ui.d.ts",
"import": "./dist/ui.js"
},
"./src/*": "./src/*",
"./*": "./dist/*"
},
"dependencies": {
Expand Down Expand Up @@ -71,6 +72,7 @@
"files": [
"/assets",
"/dist",
"/src",
"/ruffle",
"sw.js",
"ui.js",
Expand Down
91 changes: 48 additions & 43 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ const electronPreloadConfig = (/*env, argv*/) => {
const browserConfig = (/*env, argv*/) => {
const isDevServer = process.env.WEBPACK_SERVE;

/** @type {import('webpack').Configuration['entry']} */
const entry = {
ui: "./src/ui.ts",
index: "./src/index.ts",
misc: "./src/misc.ts",
};

const patterns = [{ from: "package.json", to: "_data/package.json" }];
Expand Down Expand Up @@ -188,52 +191,54 @@ const browserConfig = (/*env, argv*/) => {
return merge(tsConfig, config);
};

const libraryConfig = (/*env, argv*/) => {
const browserConf = browserConfig();
/** @type {import('webpack').Configuration} */
return {
...browserConf,
entry: {
ui: "./src/index.ts",
},

output: {
path: path.join(__dirname, "dist"),
filename: "[name].js",
library: "replaywebpage",
libraryTarget: "umd",
globalObject: "self",
publicPath: "/",
umdNamedDefine: true,
},

externals: [/^lit\/.+$/],
plugins: [
new webpack.NormalModuleReplacementPlugin(/^node:*/, (resource) => {
switch (resource.request) {
case "node:stream":
resource.request = "stream-browserify";
break;
}
}),
new webpack.ProvidePlugin({
process: "process/browser",
}),
new MiniCssExtractPlugin(),
new webpack.DefinePlugin({
__SW_NAME__: JSON.stringify("sw.js"),
__HELPER_PROXY__: JSON.stringify(HELPER_PROXY),
__GDRIVE_CLIENT_ID__: JSON.stringify(GDRIVE_CLIENT_ID),
__VERSION__: JSON.stringify(package_json.version),
}),
new webpack.BannerPlugin(BANNER_TEXT),
],
};
};
// const libraryConfig = (/*env, argv*/) => {
// const browserConf = browserConfig();
// /** @type {import('webpack').Configuration} */
// return {
// ...browserConf,
// entry: {
// index: "./src/index.ts",
// misc: "./src/misc.ts",
// "electron-replay-app": "./src/electron-replay-app.js",
// },

// output: {
// path: path.join(__dirname, "dist"),
// filename: "[name].js",
// library: "replaywebpage",
// libraryTarget: "umd",
// globalObject: "self",
// publicPath: "/",
// umdNamedDefine: true,
// },

// externals: [/^lit\/.+$/],
// plugins: [
// new webpack.NormalModuleReplacementPlugin(/^node:*/, (resource) => {
// switch (resource.request) {
// case "node:stream":
// resource.request = "stream-browserify";
// break;
// }
// }),
// new webpack.ProvidePlugin({
// process: "process/browser",
// }),
// new MiniCssExtractPlugin(),
// new webpack.DefinePlugin({
// __SW_NAME__: JSON.stringify("sw.js"),
// __HELPER_PROXY__: JSON.stringify(HELPER_PROXY),
// __GDRIVE_CLIENT_ID__: JSON.stringify(GDRIVE_CLIENT_ID),
// __VERSION__: JSON.stringify(package_json.version),
// }),
// new webpack.BannerPlugin(BANNER_TEXT),
// ],
// };
// };

module.exports = [
browserConfig,
electronMainConfig,
electronPreloadConfig,
libraryConfig,
// libraryConfig,
];

0 comments on commit a1035bc

Please sign in to comment.