Skip to content

Commit

Permalink
Add craco config for non-split build
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo-Duke committed Jan 26, 2024
1 parent b69819c commit 4083ee8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions craco-non-split.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
webpack: {
alias: {
'@terralego/core': path.resolve(__dirname, 'src/terra-front'),
},
configure: webpackConfig => {
const newWebpackConfig = webpackConfig;
const miniCssExtractPlugin = newWebpackConfig.plugins.find(
webpackPlugin => webpackPlugin instanceof MiniCssExtractPlugin,
);
if (miniCssExtractPlugin) {
miniCssExtractPlugin.options.filename = 'css/[name].css';
miniCssExtractPlugin.options.moduleFilename = () => 'static/css/main.css';
}

// For the other configuration changes modify `webpackConfig`. E.g.:
// webpackConfig.output.filename = 'js/[name].js';

newWebpackConfig.output.filename = 'static/js/[name].js';
newWebpackConfig.optimization.splitChunks = {
cacheGroups: {
default: false,
},
};
newWebpackConfig.optimization.runtimeChunk = false;

return newWebpackConfig;
},
},
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"scripts": {
"start": "craco start",
"build": "craco build && cp _headers.dist ./build/_headers",
"build:non-split": "node ./scripts/build-non-split.js",
"build:non-split": "craco build --config ./craco-non-split.config.js",
"_postbuild": "echo $npm_package_version > build/build.txt && git describe >> build/build.txt && date -R >> build/build.txt",
"version": "git changelog -n -t $npm_package_version && git add CHANGELOG.md",
"test": "craco test",
Expand Down

0 comments on commit 4083ee8

Please sign in to comment.