DocSpace-client/web/ASC.Web.Client/webpack.config.js

243 lines
6.2 KiB
JavaScript
Raw Normal View History

2021-03-10 15:31:21 +00:00
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack").container
.ModuleFederationPlugin;
2021-07-23 14:20:42 +00:00
const ExternalTemplateRemotesPlugin = require("external-remotes-plugin");
2021-03-10 15:31:21 +00:00
const TerserPlugin = require("terser-webpack-plugin");
2021-03-22 14:35:33 +00:00
const combineUrl = require("@appserver/common/utils/combineUrl");
const AppServerConfig = require("@appserver/common/constants/AppServerConfig");
const sharedDeps = require("@appserver/common/constants/sharedDependencies");
2021-03-10 15:31:21 +00:00
const path = require("path");
const pkg = require("./package.json");
const deps = pkg.dependencies;
2021-03-22 14:35:33 +00:00
const homepage = pkg.homepage; //combineUrl(AppServerConfig.proxyURL, pkg.homepage);
2021-03-10 15:31:21 +00:00
const title = pkg.title;
2021-03-01 15:21:40 +00:00
const config = {
entry: "./src/index",
mode: "development",
2021-03-01 15:21:40 +00:00
devServer: {
devMiddleware: {
publicPath: homepage,
//writeToDisk: true,
},
static: {
directory: path.join(__dirname, "dist"),
publicPath: homepage,
},
client: {
logging: "info",
// Can be used only for `errors`/`warnings`
//
// overlay: {
// errors: true,
// warnings: true,
// }
overlay: true,
progress: true,
},
port: 5001,
historyApiFallback: {
// Paths with dots should still use the history fallback.
// See https://github.com/facebook/create-react-app/issues/387.
disableDotRule: true,
index: homepage,
},
hot: false,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers":
"X-Requested-With, content-type, Authorization",
},
open: {
target: [`http://localhost:8092`],
app: {
name: "google-chrome",
arguments: ["--incognito", "--new-window"],
},
},
},
resolve: {
extensions: [".jsx", ".js", ".json"],
fallback: {
crypto: false,
},
},
output: {
publicPath: "auto",
chunkFilename: "static/js/[id].[contenthash].js",
//assetModuleFilename: "static/images/[hash][ext][query]",
2021-03-01 15:21:40 +00:00
path: path.resolve(process.cwd(), "dist"),
filename: "static/js/[name].[contenthash].bundle.js",
},
performance: {
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
module: {
rules: [
2021-03-10 16:33:10 +00:00
{
test: /\.(png|jpe?g|gif|ico)$/i,
type: "asset/resource",
generator: {
filename: "static/images/[hash][ext][query]",
},
2021-03-10 16:33:10 +00:00
},
{
test: /\.m?js/,
type: "javascript/auto",
resolve: {
fullySpecified: false,
},
},
{
test: /\.react.svg$/,
use: [
{
loader: "@svgr/webpack",
options: {
svgoConfig: {
plugins: [{ removeViewBox: false }],
},
},
},
],
},
{ test: /\.json$/, loader: "json-loader" },
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
"style-loader",
// Translates CSS into CommonJS
{
loader: "css-loader",
options: {
url: {
filter: (url, resourcePath) => {
// resourcePath - path to css file
// Don't handle `/static` urls
if (url.startsWith("/static") || url.startsWith("data:")) {
return false;
}
return true;
},
},
},
},
// Compiles Sass to CSS
"sass-loader",
],
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
options: {
presets: ["@babel/preset-react", "@babel/preset-env"],
plugins: [
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-export-default-from",
],
},
},
"source-map-loader",
],
},
],
},
plugins: [
2021-03-10 15:31:21 +00:00
new CleanWebpackPlugin(),
new ModuleFederationPlugin({
name: "studio",
filename: "remoteEntry.js",
2020-11-30 08:35:50 +00:00
remotes: {
2021-03-22 14:35:33 +00:00
studio: `studio@${combineUrl(
AppServerConfig.proxyURL,
"/remoteEntry.js"
2021-03-22 14:35:33 +00:00
)}`,
login: `login@${combineUrl(
AppServerConfig.proxyURL,
"/login/remoteEntry.js"
2021-03-22 14:35:33 +00:00
)}`,
people: `people@${combineUrl(
AppServerConfig.proxyURL,
"/products/people/remoteEntry.js"
2021-03-22 14:35:33 +00:00
)}`,
2020-11-30 08:35:50 +00:00
},
exposes: {
"./shell": "./src/Shell",
Merge branch 'develop' into feature/workspaces # Conflicts: # packages/asc-web-common/src/components/GroupSelector/GroupSelector.stories.js # packages/asc-web-common/src/components/NavMenu/sub-components/header-nav.js # packages/asc-web-common/src/components/NavMenu/sub-components/header.js # packages/asc-web-common/src/components/NavMenu/sub-components/nav-item.js # packages/asc-web-common/src/components/NavMenu/sub-components/nav-logo-item.js # packages/asc-web-common/src/components/PageLayout/index.js # packages/asc-web-common/src/components/PeopleSelector/PeopleSelector.stories.js # packages/asc-web-common/src/components/PrivateRoute/PrivateRoute.js # packages/asc-web-common/src/store/AuthStore.js # packages/asc-web-common/src/store/ModuleStore.js # packages/asc-web-common/src/store/SettingsStore.js # packages/asc-web-common/src/store/UserStore.js # packages/asc-web-common/src/store/auth/actions.js # packages/asc-web-common/src/store/auth/index.js # packages/asc-web-common/src/store/auth/reducer.js # packages/asc-web-common/src/store/auth/selectors.js # products/ASC.Files/Client/config-overrides.js # products/ASC.Files/Client/package.json # products/ASC.Files/Client/src/App.js # products/ASC.Files/Client/src/components/Article/Body/ThirdPartyList.js # products/ASC.Files/Client/src/components/Article/Body/TreeFolders.js # products/ASC.Files/Client/src/components/Article/Body/TreeSettings.js # products/ASC.Files/Client/src/components/Article/Body/index.js # products/ASC.Files/Client/src/components/Article/Header/index.js # products/ASC.Files/Client/src/components/Article/MainButton/index.js # products/ASC.Files/Client/src/components/dialogs/ConnectDialog/index.js # products/ASC.Files/Client/src/components/dialogs/ConvertDialog/index.js # products/ASC.Files/Client/src/components/dialogs/DeleteDialog/index.js # products/ASC.Files/Client/src/components/dialogs/DeleteThirdPartyDialog/index.js # products/ASC.Files/Client/src/components/dialogs/DownloadDialog/index.js # products/ASC.Files/Client/src/components/dialogs/EmptyTrashDialog/index.js # products/ASC.Files/Client/src/components/dialogs/ThirdPartyMoveDialog/index.js # products/ASC.Files/Client/src/components/pages/Home/Section/Body/BadgesFileTile.js # products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesRowContent.js # products/ASC.Files/Client/src/components/pages/Home/Section/Body/FilesTileContent.js # products/ASC.Files/Client/src/components/pages/Home/Section/Body/index.js # products/ASC.Files/Client/src/components/pages/Home/Section/Filter/index.js # products/ASC.Files/Client/src/components/pages/Home/Section/Header/index.js # products/ASC.Files/Client/src/components/pages/Home/Section/Paging/index.js # products/ASC.Files/Client/src/components/pages/Home/index.js # products/ASC.Files/Client/src/components/pages/Settings/Section/Body/ConnectedClouds.js # products/ASC.Files/Client/src/components/pages/Settings/Section/Body/index.js # products/ASC.Files/Client/src/components/pages/VersionHistory/Section/Body/VersionRow.js # products/ASC.Files/Client/src/components/pages/VersionHistory/Section/Body/index.js # products/ASC.Files/Client/src/components/pages/VersionHistory/index.js # products/ASC.Files/Client/src/components/panels/AddGroupsPanel/index.js # products/ASC.Files/Client/src/components/panels/AddUsersPanel/index.js # products/ASC.Files/Client/src/components/panels/ChangeOwnerPanel/index.js # products/ASC.Files/Client/src/components/panels/EmbeddingPanel/index.js # products/ASC.Files/Client/src/components/panels/NewFilesPanel/index.js # products/ASC.Files/Client/src/components/panels/OperationsPanel/index.js # products/ASC.Files/Client/src/components/panels/SharingPanel/AccessComboBox.js # products/ASC.Files/Client/src/components/panels/SharingPanel/SharingRow.js # products/ASC.Files/Client/src/components/panels/SharingPanel/index.js # products/ASC.Files/Client/src/components/panels/UploadPanel/ShareButton.js # products/ASC.Files/Client/src/components/panels/UploadPanel/index.js # products/ASC.Files/Client/src/components/panels/VersionHistoryPanel/index.js # products/ASC.Files/Client/src/helpers/desktop.js # products/ASC.Files/Client/src/helpers/i18n.js # products/ASC.Files/Client/src/helpers/utils.js # products/ASC.Files/Client/src/index.js # products/ASC.Files/Client/src/store/files/actions.js # products/ASC.Files/Client/src/store/files/reducers.js # products/ASC.Files/Client/src/store/rootReducer.js # products/ASC.People/Client/config-overrides.js # products/ASC.People/Client/package.json # products/ASC.People/Client/src/App.js # products/ASC.People/Client/src/components/Article/Body/index.js # products/ASC.People/Client/src/components/Article/Header/index.js # products/ASC.People/Client/src/components/Article/MainButton/index.js # products/ASC.People/Client/src/components/dialogs/ChangeEmailDialog/index.js # products/ASC.People/Client/src/components/dialogs/ChangePasswordDialog/index.js # products/ASC.People/Client/src/components/dialogs/ChangePhoneDialog/index.js # products/ASC.People/Client/src/components/dialogs/ChangeUserStatusDialog/index.js # products/ASC.People/Client/src/components/dialogs/ChangeUserTypeDialog/index.js # products/ASC.People/Client/src/components/dialogs/DataLossWarningDialog/index.js # products/ASC.People/Client/src/components/dialogs/DeleteProfileEverDialog/index.js # products/ASC.People/Client/src/components/dialogs/DeleteSelfProfileDialog/index.js # products/ASC.People/Client/src/components/dialogs/DeleteUsersDialog/index.js # products/ASC.People/Client/src/components/dialogs/InviteDialog/index.js # products/ASC.People/Client/src/components/dialogs/SendInviteDialog/index.js # products/ASC.People/Client/src/components/pages/GroupAction/Section/Body/index.js # products/ASC.People/Client/src/components/pages/GroupAction/index.js # products/ASC.People/Client/src/components/pages/Home/Section/Body/index.js # products/ASC.People/Client/src/components/pages/Home/Section/Body/userContent.js # products/ASC.People/Client/src/components/pages/Home/Section/Filter/index.js # products/ASC.People/Client/src/components/pages/Home/Section/Header/index.js # products/ASC.People/Client/src/components/pages/Home/Section/Paging/index.js # products/ASC.People/Client/src/components/pages/Home/index.js # products/ASC.People/Client/src/components/pages/Profile/Section/Body/ProfileInfo/ProfileInfo.js # products/ASC.People/Client/src/components/pages/Profile/Section/Body/index.js # products/ASC.People/Client/src/components/pages/Profile/Section/Header/index.js # products/ASC.People/Client/src/components/pages/Profile/index.js # products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/avatarEditorPage.js # products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/createAvatarEditorPage.js # products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/updateUserForm.js # products/ASC.People/Client/src/components/pages/ProfileAction/index.js # products/ASC.People/Client/src/components/pages/Reassign/Section/Header/index.js # products/ASC.People/Client/src/components/pages/Reassign/index.js # products/ASC.People/Client/src/helpers/i18n.js # products/ASC.People/Client/src/helpers/utils.js # products/ASC.People/Client/src/index.js # products/ASC.People/Client/src/store/people/reducers.js # products/ASC.People/Client/src/store/portal/actions.js # products/ASC.People/Client/src/store/portal/reducers.js # products/ASC.People/Client/src/store/profile/actions.js # products/ASC.People/Client/src/store/profile/selectors.js # products/ASC.People/Client/src/store/rootReducer.js # products/ASC.People/Client/yarn.lock # web/ASC.Web.Client/config-overrides.js # web/ASC.Web.Client/package.json # web/ASC.Web.Client/src/App.js # web/ASC.Web.Client/src/components/pages/About/index.js # web/ASC.Web.Client/src/components/pages/Confirm/index.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/activateEmail.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/activateUser.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changeEmail.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changeOwner.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changePassword.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/changePhone.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/createUser.js # web/ASC.Web.Client/src/components/pages/Confirm/sub-components/profileRemove.js # web/ASC.Web.Client/src/components/pages/Home/index.js # web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/index.js # web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/sub-components/advantagesContainer.js # web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/sub-components/buttonContainer.js # web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/sub-components/contactContainer.js # web/ASC.Web.Client/src/components/pages/PaymentsEnterprise/sub-components/headerContainer.js # web/ASC.Web.Client/src/components/pages/Settings/Layout/index.js # web/ASC.Web.Client/src/components/pages/Settings/categories/common/custom-titles.js # web/ASC.Web.Client/src/components/pages/Settings/categories/common/customization.js # web/ASC.Web.Client/src/components/pages/Settings/categories/common/language-and-time-zone.js # web/ASC.Web.Client/src/components/pages/Settings/categories/common/whitelabel.js # web/ASC.Web.Client/src/components/pages/Settings/categories/integration/sub-components/consumerModalDialog.js # web/ASC.Web.Client/src/components/pages/Settings/categories/integration/thirdPartyServicesSettings.js # web/ASC.Web.Client/src/components/pages/Settings/categories/security/accessRights.js # web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/admins.js # web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/modules.js # web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/owner.js # web/ASC.Web.Client/src/components/pages/ThirdParty/index.js # web/ASC.Web.Client/src/components/pages/Wizard/index.js # web/ASC.Web.Client/src/helpers/confirmRoute.js # web/ASC.Web.Client/src/helpers/i18n.js # web/ASC.Web.Client/src/helpers/utils.js # web/ASC.Web.Client/src/index.js # web/ASC.Web.Client/src/store/confirm/actions.js # web/ASC.Web.Client/src/store/payments/actions.js # web/ASC.Web.Client/src/store/settings/reducer.js # web/ASC.Web.Client/src/store/settings/selectors.js # web/ASC.Web.Client/src/store/store.js # web/ASC.Web.Client/src/store/wizard/actions.js # web/ASC.Web.Client/yarn.lock # web/ASC.Web.Common/package.json # web/ASC.Web.Common/yarn.lock # web/ASC.Web.Components/package.json # web/ASC.Web.Components/yarn.lock # web/ASC.Web.Login/src/Login.jsx # web/ASC.Web.Login/src/sub-components/register-container.js # yarn.lock
2021-02-24 07:30:42 +00:00
"./store": "./src/store",
"./Error404": "./src/components/pages/Errors/404/",
"./Error401": "./src/components/pages/Errors/401",
"./Error403": "./src/components/pages/Errors/403",
"./Error520": "./src/components/pages/Errors/520",
2021-03-03 09:47:28 +00:00
"./Layout": "./src/components/Layout",
"./Layout/context": "./src/components/Layout/context.js",
2021-03-03 10:02:56 +00:00
"./Main": "./src/components/Main",
"./toastr": "./src/helpers/toastr",
2020-11-30 08:35:50 +00:00
},
shared: {
...deps,
...sharedDeps,
},
}),
2021-07-23 14:20:42 +00:00
new ExternalTemplateRemotesPlugin(),
new HtmlWebpackPlugin({
template: "./public/index.html",
2021-03-01 15:21:40 +00:00
publicPath: homepage,
2021-03-10 15:31:21 +00:00
title: title,
base: `${homepage}/`,
2021-03-10 15:31:21 +00:00
}),
new CopyPlugin({
patterns: [
{
from: "public",
globOptions: {
dot: true,
gitignore: true,
ignore: ["**/index.html"],
},
},
],
}),
],
};
2021-03-01 15:21:40 +00:00
module.exports = (env, argv) => {
if (argv.mode === "production") {
config.mode = "production";
2021-03-10 15:31:21 +00:00
config.optimization = {
splitChunks: { chunks: "all" },
minimize: true,
2021-05-05 17:30:54 +00:00
minimizer: [
new TerserPlugin({
include: "./src/store",
}),
],
2021-03-10 15:31:21 +00:00
};
2021-03-01 15:21:40 +00:00
} else {
2021-03-03 14:58:16 +00:00
config.devtool = "cheap-module-source-map";
2021-03-01 15:21:40 +00:00
}
return config;
};