Split EE and CE

Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
soupette 2020-05-25 14:04:09 +02:00 committed by Alexandre Bodin
parent a8ace25056
commit 6945c6e12d
6 changed files with 54 additions and 10 deletions

View File

@ -20,6 +20,7 @@ import {
LoadingIndicatorPage,
OverlayBlocker,
} from 'strapi-helper-plugin';
import TestEE from 'ee_else_ce/containers/TestEE';
import { SETTINGS_BASE_URL, SHOW_TUTORIALS } from '../../config';
import Header from '../../components/Header/index';
@ -188,6 +189,8 @@ export class Admin extends React.Component {
<Switch>
<Route path="/" render={props => this.renderRoute(props, HomePage)} exact />
<Route path="/me" component={ProfilePage} />
{/* TODO remove this Route it is just made for the test */}
<Route path="/test" component={TestEE} />
<Route path="/plugins/:pluginId" render={this.renderPluginDispatcher} />
<Route
path="/list-plugins"

View File

@ -0,0 +1,11 @@
import React from 'react';
const Test = () => {
return (
<section style={{ textAlign: 'center' }}>
<h1>Admin test CE version</h1>
</section>
);
};
export default Test;

View File

@ -0,0 +1,11 @@
import React from 'react';
const Test = () => {
return (
<section style={{ textAlign: 'center' }}>
<h1>Admin EE version</h1>
</section>
);
};
export default Test;

View File

@ -0,0 +1,7 @@
// TODO: this condition might change
const fs = require('fs-extra');
const path = require('path');
const appSrc = path.join(__dirname, 'admin', 'src');
module.exports = fs.existsSync(path.join(appSrc, 'ee'));

View File

@ -1,3 +1,5 @@
const path = require('path');
const alias = [
'object-assign',
'whatwg-fetch',
@ -52,5 +54,6 @@ module.exports = alias.reduce(
'react-select/async-creatable': require.resolve('react-select/async-creatable'),
'react-select/base': require.resolve('react-select/base'),
'react-select/creatable': require.resolve('react-select/creatable'),
ee_else_ce: path.resolve(__dirname),
}
);

View File

@ -10,7 +10,7 @@ const TerserPlugin = require('terser-webpack-plugin');
const WebpackBar = require('webpackbar');
const isWsl = require('is-wsl');
const alias = require('./webpack.alias.js');
const IS_EE = require('./is_ee_env');
// TODO: parametrize
const URLs = {
mode: 'host',
@ -60,9 +60,7 @@ module.exports = ({
// Utilize long-term caching by adding content hashes (not compilation hashes)
// to compiled assets for production
filename: isProduction ? '[name].[contenthash:8].js' : 'bundle.js',
chunkFilename: isProduction
? '[name].[contenthash:8].chunk.js'
: '[name].chunk.js',
chunkFilename: isProduction ? '[name].[contenthash:8].chunk.js' : '[name].chunk.js',
},
optimization: {
minimize: optimize,
@ -115,9 +113,7 @@ module.exports = ({
require.resolve('@babel/plugin-proposal-class-properties'),
require.resolve('@babel/plugin-syntax-dynamic-import'),
require.resolve('@babel/plugin-transform-modules-commonjs'),
require.resolve(
'@babel/plugin-proposal-async-generator-functions'
),
require.resolve('@babel/plugin-proposal-async-generator-functions'),
[
require.resolve('@babel/plugin-transform-runtime'),
{
@ -182,16 +178,29 @@ module.exports = ({
// favicon: path.resolve(__dirname, 'admin/src/favicon.ico'),
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(
isProduction ? 'production' : 'development'
),
'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development'),
NODE_ENV: JSON.stringify(isProduction ? 'production' : 'development'),
REMOTE_URL: JSON.stringify(options.publicPath),
BACKEND_URL: JSON.stringify(options.backend),
MODE: JSON.stringify(URLs.mode), // Allow us to define the public path for the plugins assets.
PUBLIC_PATH: JSON.stringify(options.publicPath),
}),
new webpack.NormalModuleReplacementPlugin(/ee_else_ce(\.*)/, function(resource) {
// We might need to improve this if we want to make it work with components
const containerPathName = resource.context.split('/containers/');
if (IS_EE) {
resource.request = resource.request.replace(
/ee_else_ce/,
path.join(containerPathName[0], 'ee')
);
} else {
resource.request = resource.request.replace(
/ee_else_ce/,
path.join(containerPathName[0])
);
}
}),
...webpackPlugins,
],
};