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');
|
|
|
|
|
2021-06-23 20:18:13 +02:00
|
|
|
const webpackConfig = require('./webpack.config');
|
2019-05-20 17:13:14 +02:00
|
|
|
|
|
|
|
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;
|
2021-05-05 15:21:53 +02:00
|
|
|
const entry = path.join(__dirname, 'admin', 'src');
|
2019-05-20 17:13:14 +02:00
|
|
|
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',
|
2021-05-05 10:48:27 +02:00
|
|
|
adminPath: '/admin/',
|
2019-05-20 17:13:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const args = {
|
|
|
|
entry,
|
|
|
|
dest,
|
|
|
|
env,
|
|
|
|
options,
|
|
|
|
};
|
|
|
|
|
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,
|
2021-06-02 09:24:03 +02:00
|
|
|
snapshot: {
|
|
|
|
managedPaths: [
|
2021-06-02 13:45:22 +02:00
|
|
|
path.resolve(__dirname, '../content-type-builder'),
|
|
|
|
path.resolve(__dirname, '../upload'),
|
|
|
|
path.resolve(__dirname, '../helper-plugin'),
|
2021-06-02 09:24:03 +02:00
|
|
|
],
|
|
|
|
buildDependencies: {
|
|
|
|
hash: true,
|
|
|
|
timestamp: true,
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
timestamp: true,
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
timestamp: true,
|
|
|
|
},
|
|
|
|
resolveBuildDependencies: {
|
|
|
|
hash: true,
|
|
|
|
timestamp: true,
|
|
|
|
},
|
|
|
|
},
|
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
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|