Merge branch 'release/v1.2' of github.com:ONLYOFFICE/AppServer into release/v1.2

This commit is contained in:
Nikita Gopienko 2022-04-28 12:04:20 +03:00
commit 05cc5d336b
20 changed files with 278 additions and 197 deletions

View File

@ -1,3 +1,5 @@
@echo off
echo "##########################################################"
echo "######### Start build and deploy Personal ##############"
echo "##########################################################"
@ -6,6 +8,7 @@ echo.
PUSHD %~dp0
call runasadmin.bat "%~dpnx0"
if %errorlevel% == 0 (
call start\stop.bat nopause
@ -18,7 +21,11 @@ call build\build.static.bat nopause personal
echo "BACK-END"
call build\build.backend.bat nopause
start /b call build\start\start.bat nopause
PUSHD %~dp0
call start\start.bat nopause
echo.
pause
)

View File

@ -14,7 +14,7 @@
],
"scripts": {
"build": "lerna run build --parallel --ignore @appserver/common --ignore @appserver/components --ignore @appserver/browserslist-config-asc",
"build:personal": "lerna run build --parallel --scope {@appserver/studio,@appserver/people,@appserver/files,@appserver/editor}",
"build:personal": "lerna run build:personal --parallel --scope {@appserver/studio,@appserver/people,@appserver/files,@appserver/editor}",
"build:test": "lerna run build:test --parallel --ignore @appserver/common --ignore @appserver/components --ignore @appserver/browserslist-config-asc --ignore @appserver/debug-info",
"build:test.translation": "lerna run build:test.translation --parallel --ignore @appserver/common --ignore @appserver/components --ignore @appserver/browserslist-config-asc --ignore @appserver/debug-info",
"bump": "lerna version --no-push --no-git-tag-version",
@ -23,7 +23,7 @@
"deploy:personal": "shx rm -rf build/deploy/products && shx rm -rf build/deploy/public && shx rm -rf build/deploy/studio && lerna run deploy --parallel --scope {@appserver/studio,@appserver/people,@appserver/files,@appserver/editor} && shx cp -r public build/deploy",
"serve": "lerna run serve --parallel --ignore @appserver/common --ignore @appserver/components --ignore @appserver/browserslist-config-asc",
"start": "lerna run start --parallel --ignore @appserver/common --ignore @appserver/components --ignore @appserver/browserslist-config-asc",
"start:personal": "lerna run start --parallel --scope {@appserver/studio,@appserver/people,@appserver/files,@appserver/editor}",
"start:personal": "lerna run start:personal --parallel --scope {@appserver/studio,@appserver/people,@appserver/files,@appserver/editor}",
"start-prod": "lerna run start-prod --parallel --ignore @appserver/common --ignore @appserver/components --ignore @appserver/browserslist-config-asc",
"storybook": "yarn workspace @appserver/components storybook",
"storybook-build": "yarn workspace @appserver/components run storybook-build",

View File

@ -229,6 +229,7 @@ class Section extends React.Component {
snackbarExist,
showText,
infoPanelIsVisible,
isInfoPanelAvailable,
} = this.props;
let sectionHeaderContent = null;
@ -467,12 +468,16 @@ class Section extends React.Component {
<></>
)}
</SectionContainer>
<InfoPanel>
<SubInfoPanelHeader>
{infoPanelHeaderContent}
</SubInfoPanelHeader>
<SubInfoPanelBody>{infoPanelBodyContent}</SubInfoPanelBody>
</InfoPanel>
{isInfoPanelAvailable && (
<InfoPanel>
<SubInfoPanelHeader>
{infoPanelHeaderContent}
</SubInfoPanelHeader>
<SubInfoPanelBody>
{infoPanelBodyContent}
</SubInfoPanelBody>
</InfoPanel>
)}
</Provider>
)}
</ReactResizeDetector>
@ -539,11 +544,13 @@ Section.propTypes = {
isHeaderVisible: PropTypes.bool,
firstLoad: PropTypes.bool,
isHomepage: PropTypes.bool,
isInfoPanelAvailable: PropTypes.bool,
};
Section.defaultProps = {
withBodyScroll: true,
withBodyAutoFocus: false,
isInfoPanelAvailable: true,
};
Section.InfoPanelHeader = InfoPanelHeader;

View File

@ -15,6 +15,7 @@ import { isMobile } from "react-device-detect";
const StyledInfoPanelWrapper = styled.div.attrs(({ id }) => ({
id: id,
}))`
user-select: none;
height: auto;
width: auto;
background: rgba(6, 22, 38, 0.2);

View File

@ -5,12 +5,14 @@
"homepage": "/products/files",
"scripts": {
"build": "webpack --mode production",
"build:personal": "webpack --mode production --env personal=true",
"build:test": "webpack --env minimize=false --mode production",
"build:test.translation": "webpack --env minimize=false hideText=true --mode production",
"clean": "shx rm -rf dist",
"deploy": "shx --silent mkdir -p ../../../build/deploy/products/ASC.Files/client && shx cp -r dist/* ../../../build/deploy/products/ASC.Files/client",
"serve": "serve dist -p 5008",
"start": "webpack-cli serve",
"start:personal": "webpack-cli serve --env personal=true",
"start-prod": "webpack --mode production && serve dist -p 5008",
"test:codeceptjs": "npx codeceptjs run --reporter mocha-multi",
"test:mobile": "cross-env DEVICE_TYPE=mobile yarn test:codeceptjs",

View File

@ -104,7 +104,7 @@ const Badges = ({
const lineHeightBadge = isTile || tabletViewBadge ? "1.46" : "1.34";
const paddingBadge = isTile || tabletViewBadge ? "0 5px" : "0 3px";
const paddingBadge = "0 5px";
const fontSizeBadge = isTile || tabletViewBadge ? "11px" : "9px";

View File

@ -154,7 +154,7 @@ const StyledBadgesContainer = styled.div`
.badge-version {
width: max-content;
margin: -2px 6px -2px -2px;
margin: 0 6px -2px -2px;
}
.badge-new-version {

View File

@ -46,7 +46,7 @@ const PureSettings = ({
}, [title, t]);
return (
<Section>
<Section isInfoPanelAvailable={false}>
<Section.SectionHeader>
{(!isLoadedSettingsTree && isLoading) || isLoading || !tReady ? (
<Loaders.SectionHeader />

View File

@ -5,6 +5,8 @@ const ModuleFederationPlugin = require("webpack").container
.ModuleFederationPlugin;
const ExternalTemplateRemotesPlugin = require("external-remotes-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const DefinePlugin = require("webpack").DefinePlugin;
const combineUrl = require("@appserver/common/utils/combineUrl");
const AppServerConfig = require("@appserver/common/constants/AppServerConfig");
const sharedDeps = require("@appserver/common/constants/sharedDependencies");
@ -249,5 +251,11 @@ module.exports = (env, argv) => {
config.devtool = "cheap-module-source-map";
}
config.plugins.push(
new DefinePlugin({
IS_PERSONAL: env.personal || false,
})
);
return config;
};

View File

@ -5,12 +5,14 @@
"homepage": "/products/people",
"scripts": {
"build": "webpack --mode production",
"build:personal": "webpack --mode production --env personal=true",
"build:test": "webpack --env minimize=false --mode production",
"build:test.translation": "webpack --env minimize=false hideText=true --mode production",
"clean": "shx rm -rf dist",
"deploy": "shx --silent mkdir -p ../../../build/deploy/products/ASC.People/client && shx cp -r dist/* ../../../build/deploy/products/ASC.People/client",
"serve": "serve dist -p 5002",
"start": "webpack-cli serve",
"start:personal": "webpack-cli serve --env personal=true",
"start-prod": "webpack --mode production && serve dist -p 5002",
"test:codeceptjs": "npx codeceptjs run --reporter mocha-multi",
"test:mobile": "cross-env DEVICE_TYPE=mobile yarn test:codeceptjs",

View File

@ -93,6 +93,10 @@ const IconButtonWrapper = styled.div`
}
`;
const LangSelectorContainer = styled.div`
display: flex;
`;
class ProfileInfo extends React.PureComponent {
constructor(props) {
super(props);
@ -268,7 +272,7 @@ class ProfileInfo extends React.PureComponent {
<Link
color={theme.profileInfo.tooltipLinkColor}
isHovered={true}
href="https://helpcenter.onlyoffice.com/ru/guides/become-translator.aspx"
href={`https://helpcenter.onlyoffice.com/${language}/guides/become-translator.aspx`}
target="_blank"
>
{t("Common:LearnMore")}
@ -376,7 +380,7 @@ class ProfileInfo extends React.PureComponent {
<InfoItemLabel>{t("Common:Language")}:</InfoItemLabel>
<InfoItemValue>
{cultureNames ? (
<>
<LangSelectorContainer>
<ComboBox
directionY="both"
options={cultureNames}
@ -400,7 +404,7 @@ class ProfileInfo extends React.PureComponent {
helpButtonHeaderContent={t("Common:Language")}
className="help-icon"
/>
</>
</LangSelectorContainer>
) : (
<Loaders.Text />
)}

View File

@ -326,7 +326,7 @@ class SectionHeaderContent extends React.PureComponent {
{
key: "edit",
className: "header-context-menu_edit",
label: t("EditUser"),
label: t("Profile:EditUser"),
onClick: this.onEditClick,
},
{

View File

@ -685,7 +685,8 @@ class UpdateUserForm extends React.Component {
<Link
color="#316DAA"
isHovered={true}
href="https://helpcenter.onlyoffice.com/ru/gettingstarted/people.aspx#ManagingAccessRights_block"
href={`https://helpcenter.onlyoffice.com/${language}/gettingstarted/people.aspx#ManagingAccessRights_block`}
target="_blank"
style={{ marginTop: 23 }}
>
{t("TermsOfUsePopupHelperLink")}

View File

@ -1,29 +1,32 @@
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ModuleFederationPlugin = require('webpack').container.ModuleFederationPlugin;
const ExternalTemplateRemotesPlugin = require('external-remotes-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const combineUrl = require('@appserver/common/utils/combineUrl');
const AppServerConfig = require('@appserver/common/constants/AppServerConfig');
const sharedDeps = require('@appserver/common/constants/sharedDependencies');
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack").container
.ModuleFederationPlugin;
const ExternalTemplateRemotesPlugin = require("external-remotes-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const DefinePlugin = require("webpack").DefinePlugin;
const path = require('path');
const pkg = require('./package.json');
const combineUrl = require("@appserver/common/utils/combineUrl");
const AppServerConfig = require("@appserver/common/constants/AppServerConfig");
const sharedDeps = require("@appserver/common/constants/sharedDependencies");
const path = require("path");
const pkg = require("./package.json");
const deps = pkg.dependencies || {};
const homepage = pkg.homepage; //combineUrl(AppServerConfig.proxyURL, pkg.homepage);
const title = pkg.title;
var config = {
mode: 'development',
entry: './src/index',
mode: "development",
entry: "./src/index",
devServer: {
devMiddleware: {
publicPath: homepage,
},
static: {
directory: path.join(__dirname, 'dist'),
directory: path.join(__dirname, "dist"),
publicPath: homepage,
},
port: 5002,
@ -35,22 +38,23 @@ var config = {
},
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',
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers":
"X-Requested-With, content-type, Authorization",
},
},
output: {
publicPath: 'auto',
chunkFilename: 'static/js/[id].[contenthash].js',
publicPath: "auto",
chunkFilename: "static/js/[id].[contenthash].js",
//assetModuleFilename: "static/images/[hash][ext][query]",
path: path.resolve(process.cwd(), 'dist'),
filename: 'static/js/[name].[contenthash].bundle.js',
path: path.resolve(process.cwd(), "dist"),
filename: "static/js/[name].[contenthash].bundle.js",
},
resolve: {
extensions: ['.jsx', '.js', '.json'],
extensions: [".jsx", ".js", ".json"],
fallback: {
crypto: false,
},
@ -65,14 +69,14 @@ var config = {
rules: [
{
test: /\.(png|jpe?g|gif|ico)$/i,
type: 'asset/resource',
type: "asset/resource",
generator: {
filename: 'static/images/[hash][ext][query]',
filename: "static/images/[hash][ext][query]",
},
},
{
test: /\.m?js/,
type: 'javascript/auto',
type: "javascript/auto",
resolve: {
fullySpecified: false,
},
@ -81,7 +85,7 @@ var config = {
test: /\.react.svg$/,
use: [
{
loader: '@svgr/webpack',
loader: "@svgr/webpack",
options: {
svgoConfig: {
plugins: [{ removeViewBox: false }],
@ -90,26 +94,26 @@ var config = {
},
],
},
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.json$/, loader: "json-loader" },
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
use: ["style-loader", "css-loader"],
},
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
"style-loader",
// Translates CSS into CommonJS
{
loader: 'css-loader',
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:')) {
if (url.startsWith("/static") || url.startsWith("data:")) {
return false;
}
@ -119,7 +123,7 @@ var config = {
},
},
// Compiles Sass to CSS
'sass-loader',
"sass-loader",
],
},
@ -128,17 +132,17 @@ var config = {
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
loader: "babel-loader",
options: {
presets: ['@babel/preset-react', '@babel/preset-env'],
presets: ["@babel/preset-react", "@babel/preset-env"],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-export-default-from",
],
},
},
'source-map-loader',
"source-map-loader",
],
},
],
@ -147,19 +151,25 @@ var config = {
plugins: [
new CleanWebpackPlugin(),
new ModuleFederationPlugin({
name: 'people',
filename: 'remoteEntry.js',
name: "people",
filename: "remoteEntry.js",
remotes: {
studio: `studio@${combineUrl(AppServerConfig.proxyURL, '/remoteEntry.js')}`,
people: `people@${combineUrl(AppServerConfig.proxyURL, '/products/people/remoteEntry.js')}`,
studio: `studio@${combineUrl(
AppServerConfig.proxyURL,
"/remoteEntry.js"
)}`,
people: `people@${combineUrl(
AppServerConfig.proxyURL,
"/products/people/remoteEntry.js"
)}`,
},
exposes: {
'./app': './src/People.jsx',
'./GroupSelector': './src/components/GroupSelector',
'./PeopleSelector': './src/components/PeopleSelector',
'./PeopleSelector/UserTooltip':
'./src/components/PeopleSelector/sub-components/UserTooltip.js',
'./MyProfile': './src/pages/My',
"./app": "./src/People.jsx",
"./GroupSelector": "./src/components/GroupSelector",
"./PeopleSelector": "./src/components/PeopleSelector",
"./PeopleSelector/UserTooltip":
"./src/components/PeopleSelector/sub-components/UserTooltip.js",
"./MyProfile": "./src/pages/My",
},
shared: {
...deps,
@ -170,11 +180,11 @@ var config = {
new CopyPlugin({
patterns: [
{
from: 'public',
from: "public",
globOptions: {
dot: true,
gitignore: true,
ignore: ['**/index.html'],
ignore: ["**/index.html"],
},
},
],
@ -187,7 +197,7 @@ module.exports = (env, argv) => {
config.plugins = [
...config.plugins,
new HtmlWebpackPlugin({
template: './public/index.html',
template: "./public/index.html",
publicPath: homepage,
title: title,
base: `${homepage}/`,
@ -213,24 +223,30 @@ module.exports = (env, argv) => {
config.plugins = [
...config.plugins,
new HtmlWebpackPlugin({
template: './public/index.html',
template: "./public/index.html",
publicPath: homepage,
title: title,
base: `${homepage}/`,
custom: '',
custom: "",
}),
];
}
if (argv.mode === 'production') {
config.mode = 'production';
if (argv.mode === "production") {
config.mode = "production";
config.optimization = {
splitChunks: { chunks: 'all' },
splitChunks: { chunks: "all" },
minimize: !env.minimize,
minimizer: [new TerserPlugin()],
};
} else {
config.devtool = 'cheap-module-source-map';
config.devtool = "cheap-module-source-map";
}
config.plugins.push(
new DefinePlugin({
IS_PERSONAL: env.personal || false,
})
);
return config;
};

View File

@ -5,12 +5,14 @@
"homepage": "",
"scripts": {
"build": "webpack --mode production",
"build:personal": "webpack --mode production --env personal=true",
"build:test": "webpack --env minimize=false --mode production",
"build:test.translation": "webpack --env minimize=false hideText=true --mode production",
"clean": "shx rm -rf dist",
"deploy": "shx --silent mkdir -p ../../build/deploy/studio/client && shx cp -r dist/* ../../build/deploy/studio/client",
"serve": "serve dist -p 5001",
"start": "webpack-cli serve",
"start:personal": "webpack-cli serve --env personal=true",
"start-prod": "webpack --mode production && serve dist -p 5001",
"test:codeceptjs": "npx codeceptjs run --reporter mocha-multi",
"test:mobile": "cross-env DEVICE_TYPE=mobile yarn test:codeceptjs",

View File

@ -61,9 +61,10 @@ const About = React.lazy(() => import("./components/pages/About"));
const Wizard = React.lazy(() => import("./components/pages/Wizard"));
const Settings = React.lazy(() => import("./components/pages/Settings"));
const ComingSoon = React.lazy(() => import("./components/pages/ComingSoon"));
const Confirm = React.lazy(() => import("./components/pages/Confirm"));
const Confirm =
!IS_PERSONAL && React.lazy(() => import("./components/pages/Confirm"));
const MyProfile = React.lazy(() => import("people/MyProfile"));
const EnterCode = React.lazy(() => import("login/codeLogin"));
const EnterCode = !IS_PERSONAL && React.lazy(() => import("login/codeLogin"));
const InvalidError = React.lazy(() =>
import("./components/pages/Errors/Invalid")
);
@ -109,13 +110,15 @@ const HomeRoute = (props) => (
</React.Suspense>
);
const ConfirmRoute = (props) => (
<React.Suspense fallback={<AppLoader />}>
<ErrorBoundary>
<Confirm {...props} />
</ErrorBoundary>
</React.Suspense>
);
const ConfirmRoute =
!IS_PERSONAL &&
((props) => (
<React.Suspense fallback={<AppLoader />}>
<ErrorBoundary>
<Confirm {...props} />
</ErrorBoundary>
</React.Suspense>
));
const PreparationPortalRoute = (props) => (
<React.Suspense fallback={<AppLoader />}>
@ -157,13 +160,15 @@ const MyProfileRoute = (props) => (
</React.Suspense>
);
const EnterCodeRoute = (props) => (
<React.Suspense fallback={<AppLoader />}>
<ErrorBoundary>
<EnterCode {...props} />
</ErrorBoundary>
</React.Suspense>
);
const EnterCodeRoute =
!IS_PERSONAL &&
((props) => (
<React.Suspense fallback={<AppLoader />}>
<ErrorBoundary>
<EnterCode {...props} />
</ErrorBoundary>
</React.Suspense>
));
const InvalidRoute = (props) => (
<React.Suspense fallback={<AppLoader />}>
@ -469,7 +474,7 @@ const Shell = ({ items = [], page = "home", ...rest }) => {
const loginRoutes = [];
if (isLoaded && !personal) {
if (isLoaded && !IS_PERSONAL) {
let module;
if (roomsMode) {
module = "./roomsLogin";
@ -495,7 +500,7 @@ const Shell = ({ items = [], page = "home", ...rest }) => {
const roomsRoutes = [];
if (roomsMode) {
if (!IS_PERSONAL && roomsMode) {
roomsRoutes.push(
<Route path={ENTER_CODE_URL} component={EnterCodeRoute} />
);
@ -514,7 +519,9 @@ const Shell = ({ items = [], page = "home", ...rest }) => {
<PrivateRoute path={ABOUT_URL} component={AboutRoute} />
{loginRoutes}
{roomsRoutes}
<Route path={CONFIRM_URL} component={ConfirmRoute} />
{!IS_PERSONAL && (
<Route path={CONFIRM_URL} component={ConfirmRoute} />
)}
<Route path={INVALID_URL} component={InvalidRoute} />
<PrivateRoute
path={COMING_SOON_URLS}

View File

@ -170,46 +170,6 @@ const config = {
plugins: [
new CleanWebpackPlugin(),
new ModuleFederationPlugin({
name: "studio",
filename: "remoteEntry.js",
remotes: {
studio: `studio@${combineUrl(
AppServerConfig.proxyURL,
"/remoteEntry.js"
)}`,
people: `people@${combineUrl(
AppServerConfig.proxyURL,
"/products/people/remoteEntry.js"
)}`,
login: `login@${combineUrl(
AppServerConfig.proxyURL,
"/login/remoteEntry.js"
)}`,
files: `files@${combineUrl(
AppServerConfig.proxyURL,
"/products/files/remoteEntry.js"
)}`,
},
exposes: {
"./shell": "./src/Shell",
"./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",
"./Layout": "./src/components/Layout",
"./Layout/context": "./src/components/Layout/context.js",
"./Main": "./src/components/Main",
"./toastr": "./src/helpers/toastr",
"./PreparationPortalDialog":
"./src/components/dialogs/PreparationPortalDialog/PreparationPortalDialogWrapper.js",
},
shared: {
...deps,
...sharedDeps,
},
}),
new ExternalTemplateRemotesPlugin(),
new HtmlWebpackPlugin({
template: "./public/index.html",
@ -229,14 +189,6 @@ const config = {
},
],
}),
new DefinePlugin({
VERSION: JSON.stringify(version),
BUILD_AT: DefinePlugin.runtimeValue(function () {
const timeElapsed = Date.now();
const today = new Date(timeElapsed);
return JSON.stringify(today.toISOString().split(".")[0] + "Z");
}, true),
}),
],
};
@ -252,5 +204,62 @@ module.exports = (env, argv) => {
config.devtool = "cheap-module-source-map";
}
const remotes = {
studio: `studio@${combineUrl(AppServerConfig.proxyURL, "/remoteEntry.js")}`,
people: `people@${combineUrl(
AppServerConfig.proxyURL,
"/products/people/remoteEntry.js"
)}`,
files: `files@${combineUrl(
AppServerConfig.proxyURL,
"/products/files/remoteEntry.js"
)}`,
};
if (!env.personal) {
remotes.login = `login@${combineUrl(
AppServerConfig.proxyURL,
"/login/remoteEntry.js"
)}`;
}
config.plugins.push(
new ModuleFederationPlugin({
name: "studio",
filename: "remoteEntry.js",
remotes: remotes,
exposes: {
"./shell": "./src/Shell",
"./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",
"./Layout": "./src/components/Layout",
"./Layout/context": "./src/components/Layout/context.js",
"./Main": "./src/components/Main",
"./toastr": "./src/helpers/toastr",
"./PreparationPortalDialog":
"./src/components/dialogs/PreparationPortalDialog/PreparationPortalDialogWrapper.js",
},
shared: {
...deps,
...sharedDeps,
},
})
);
const defines = {
VERSION: JSON.stringify(version),
BUILD_AT: DefinePlugin.runtimeValue(function () {
const timeElapsed = Date.now();
const today = new Date(timeElapsed);
return JSON.stringify(today.toISOString().split(".")[0] + "Z");
}, true),
IS_PERSONAL: env.personal || false,
};
config.plugins.push(new DefinePlugin(defines));
return config;
};

View File

@ -5,12 +5,14 @@
"homepage": "/products/files/doceditor",
"scripts": {
"build": "webpack --mode production",
"build:personal": "webpack --mode production --env personal=true",
"build:test": "webpack --env minimize=false --mode production",
"build:test.translation": "webpack --env minimize=false hideText=true --mode production",
"clean": "shx rm -rf dist",
"deploy": "shx --silent mkdir -p ../../build/deploy/products/ASC.Files/editor && shx cp -r dist/* ../../build/deploy/products/ASC.Files/editor",
"serve": "serve dist -p 5013",
"start": "webpack-cli serve",
"start:personal": "webpack-cli serve --env personal=true",
"start-prod": "webpack --mode production && serve dist -p 5013"
},
"devDependencies": {

View File

@ -73,11 +73,11 @@ let fileInfo;
let successAuth;
let isSharingAccess;
let user = null;
let personal;
let personal = IS_PERSONAL || null;
let config;
let url = window.location.href;
const filesUrl = url.substring(0, url.indexOf("/doceditor"));
const doc = url.indexOf("doc=") !== -1 ? url.split("doc=")[1] : null;
//const doc = url.indexOf("doc=") !== -1 ? url.split("doc=")[1] : null;
toast.configure();
@ -346,13 +346,13 @@ const Editor = () => {
if (!favicon) return;
let icon = null;
switch (documentType) {
case "text":
case text:
icon = "text.ico";
break;
case "presentation":
case presentation:
icon = "presentation.ico";
break;
case "spreadsheet":
case spreadSheet:
icon = "spreadsheet.ico";
break;
default:

View File

@ -1,32 +1,35 @@
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ModuleFederationPlugin = require('webpack').container.ModuleFederationPlugin;
const ExternalTemplateRemotesPlugin = require('external-remotes-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const combineUrl = require('@appserver/common/utils/combineUrl');
const AppServerConfig = require('@appserver/common/constants/AppServerConfig');
const sharedDeps = require('@appserver/common/constants/sharedDependencies');
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack").container
.ModuleFederationPlugin;
const ExternalTemplateRemotesPlugin = require("external-remotes-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const DefinePlugin = require("webpack").DefinePlugin;
const combineUrl = require("@appserver/common/utils/combineUrl");
const AppServerConfig = require("@appserver/common/constants/AppServerConfig");
const sharedDeps = require("@appserver/common/constants/sharedDependencies");
const { proxyURL } = AppServerConfig;
const path = require('path');
const pkg = require('./package.json');
const path = require("path");
const pkg = require("./package.json");
const deps = pkg.dependencies || {};
const homepage = pkg.homepage; // combineUrl(AppServerConfig.proxyURL, pkg.homepage);
const title = pkg.title;
const config = {
entry: './src/index',
target: 'web',
mode: 'development',
entry: "./src/index",
target: "web",
mode: "development",
devServer: {
devMiddleware: {
publicPath: homepage,
},
static: {
directory: path.join(__dirname, 'dist'),
directory: path.join(__dirname, "dist"),
publicPath: homepage,
},
port: 5013,
@ -38,25 +41,26 @@ const config = {
},
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',
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers":
"X-Requested-With, content-type, Authorization",
},
},
resolve: {
extensions: ['.jsx', '.js', '.json'],
extensions: [".jsx", ".js", ".json"],
fallback: {
crypto: false,
},
},
output: {
publicPath: 'auto',
chunkFilename: 'static/js/[id].[contenthash].js',
publicPath: "auto",
chunkFilename: "static/js/[id].[contenthash].js",
//assetModuleFilename: "static/images/[hash][ext][query]",
path: path.resolve(process.cwd(), 'dist'),
filename: 'static/js/[name].[contenthash].bundle.js',
path: path.resolve(process.cwd(), "dist"),
filename: "static/js/[name].[contenthash].bundle.js",
},
performance: {
@ -68,14 +72,14 @@ const config = {
rules: [
{
test: /\.(png|jpe?g|gif|ico)$/i,
type: 'asset/resource',
type: "asset/resource",
generator: {
filename: 'static/images/[hash][ext][query]',
filename: "static/images/[hash][ext][query]",
},
},
{
test: /\.m?js/,
type: 'javascript/auto',
type: "javascript/auto",
resolve: {
fullySpecified: false,
},
@ -84,7 +88,7 @@ const config = {
test: /\.react.svg$/,
use: [
{
loader: '@svgr/webpack',
loader: "@svgr/webpack",
options: {
svgoConfig: {
plugins: [{ removeViewBox: false }],
@ -93,26 +97,26 @@ const config = {
},
],
},
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.json$/, loader: "json-loader" },
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
use: ["style-loader", "css-loader"],
},
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
"style-loader",
// Translates CSS into CommonJS
{
loader: 'css-loader',
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:')) {
if (url.startsWith("/static") || url.startsWith("data:")) {
return false;
}
@ -122,7 +126,7 @@ const config = {
},
},
// Compiles Sass to CSS
'sass-loader',
"sass-loader",
],
},
@ -131,17 +135,17 @@ const config = {
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
loader: "babel-loader",
options: {
presets: ['@babel/preset-react', '@babel/preset-env'],
presets: ["@babel/preset-react", "@babel/preset-env"],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-export-default-from",
],
},
},
'source-map-loader',
"source-map-loader",
],
},
],
@ -150,14 +154,17 @@ const config = {
plugins: [
new CleanWebpackPlugin(),
new ModuleFederationPlugin({
name: 'editor',
filename: 'remoteEntry.js',
name: "editor",
filename: "remoteEntry.js",
remotes: {
studio: `studio@${combineUrl(proxyURL, '/remoteEntry.js')}`,
files: `files@${combineUrl(proxyURL, '/products/files/remoteEntry.js')}`,
studio: `studio@${combineUrl(proxyURL, "/remoteEntry.js")}`,
files: `files@${combineUrl(
proxyURL,
"/products/files/remoteEntry.js"
)}`,
},
exposes: {
'./app': './src/Editor.jsx',
"./app": "./src/Editor.jsx",
},
shared: {
...deps,
@ -166,7 +173,7 @@ const config = {
}),
new ExternalTemplateRemotesPlugin(),
new HtmlWebpackPlugin({
template: './public/index.html',
template: "./public/index.html",
publicPath: homepage,
title: title,
base: `${homepage}/`,
@ -174,11 +181,11 @@ const config = {
new CopyPlugin({
patterns: [
{
from: 'public',
from: "public",
globOptions: {
dot: true,
gitignore: true,
ignore: ['**/index.html'],
ignore: ["**/index.html"],
},
},
],
@ -187,16 +194,22 @@ const config = {
};
module.exports = (env, argv) => {
if (argv.mode === 'production') {
config.mode = 'production';
if (argv.mode === "production") {
config.mode = "production";
config.optimization = {
splitChunks: { chunks: 'all' },
splitChunks: { chunks: "all" },
minimize: !env.minimize,
minimizer: [new TerserPlugin()],
};
} else {
config.devtool = 'cheap-module-source-map';
config.devtool = "cheap-module-source-map";
}
config.plugins.push(
new DefinePlugin({
IS_PERSONAL: env.personal || false,
})
);
return config;
};