2020-10-27 11:27:17 +01:00
|
|
|
'use strict';
|
|
|
|
|
2019-05-20 17:13:14 +02:00
|
|
|
const path = require('path');
|
2021-01-25 14:37:57 +01:00
|
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
2021-05-03 16:33:46 +02:00
|
|
|
const { DuplicateReporterPlugin } = require('duplicate-dependencies-webpack-plugin');
|
|
|
|
|
2019-05-20 17:13:14 +02:00
|
|
|
const webpackConfig = require('./webpack.config.js');
|
|
|
|
|
|
|
|
module.exports = () => {
|
2021-01-25 14:37:57 +01:00
|
|
|
const analyzeBundle = process.env.ANALYZE_BUNDLE;
|
2021-05-03 16:33:46 +02:00
|
|
|
const analyzeDuplicateDependencies = process.env.ANALYZE_DEPS;
|
2019-05-20 17:13:14 +02:00
|
|
|
const entry = path.join(__dirname, 'admin', 'src', 'app.js');
|
|
|
|
const dest = path.join(__dirname, 'build');
|
2021-01-25 14:37:57 +01:00
|
|
|
|
|
|
|
// When running the analyze:bundle command, it needs a production build
|
|
|
|
// to display the tree map of modules
|
|
|
|
const env = analyzeBundle ? 'production' : 'development';
|
2019-05-20 17:13:14 +02:00
|
|
|
const options = {
|
|
|
|
backend: 'http://localhost:1337',
|
|
|
|
publicPath: '/admin/',
|
2021-02-11 15:49:12 +01:00
|
|
|
features: process.env.ENABLED_EE_FEATURES || ['sso'],
|
2019-05-20 17:13:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const args = {
|
|
|
|
entry,
|
|
|
|
dest,
|
|
|
|
env,
|
|
|
|
options,
|
2020-07-01 14:02:39 +02:00
|
|
|
useEE: process.env.STRAPI_DISABLE_EE === 'true' ? false : true,
|
2019-05-20 17:13:14 +02:00
|
|
|
};
|
|
|
|
|
2021-01-25 14:37:57 +01:00
|
|
|
const config = webpackConfig(args);
|
|
|
|
|
|
|
|
if (analyzeBundle) {
|
|
|
|
config.plugins.push(new BundleAnalyzerPlugin());
|
|
|
|
}
|
|
|
|
|
2021-05-03 16:33:46 +02:00
|
|
|
if (analyzeDuplicateDependencies === 'true') {
|
|
|
|
config.plugins.push(new DuplicateReporterPlugin());
|
|
|
|
}
|
|
|
|
|
2019-05-20 17:13:14 +02:00
|
|
|
return {
|
2021-01-25 14:37:57 +01:00
|
|
|
...config,
|
2019-05-20 17:13:14 +02:00
|
|
|
devServer: {
|
|
|
|
port: 4000,
|
|
|
|
clientLogLevel: 'none',
|
|
|
|
quiet: true,
|
|
|
|
historyApiFallback: {
|
|
|
|
index: '/admin/',
|
2019-11-05 09:07:03 +01:00
|
|
|
disableDotRule: true,
|
2019-05-20 17:13:14 +02:00
|
|
|
},
|
2020-04-21 17:25:34 +02:00
|
|
|
open: false,
|
2019-11-08 20:46:43 +01:00
|
|
|
openPage: '/admin',
|
2019-05-20 17:13:14 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|