2020-02-18 07:57:00 +00:00
|
|
|
|
const path = require("path");
|
2020-10-08 08:20:14 +00:00
|
|
|
|
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
2021-01-26 15:39:50 +00:00
|
|
|
|
const webpack = require("webpack");
|
2020-02-18 07:57:00 +00:00
|
|
|
|
|
2018-05-18 09:28:29 +00:00
|
|
|
|
module.exports = {
|
2020-02-18 07:57:00 +00:00
|
|
|
|
outputDir: path.resolve(__dirname, "../priv/static"),
|
2020-10-08 08:20:14 +00:00
|
|
|
|
configureWebpack: (config) => {
|
|
|
|
|
// Limit the used memory when building
|
|
|
|
|
// Source : https://stackoverflow.com/a/55810460/10204399
|
|
|
|
|
// get a reference to the existing ForkTsCheckerWebpackPlugin
|
|
|
|
|
const existingForkTsChecker = config.plugins.filter(
|
|
|
|
|
(p) => p instanceof ForkTsCheckerWebpackPlugin
|
|
|
|
|
)[0];
|
|
|
|
|
|
|
|
|
|
// remove the existing ForkTsCheckerWebpackPlugin
|
|
|
|
|
// so that we can replace it with our modified version
|
2020-11-30 09:24:11 +00:00
|
|
|
|
config.plugins = config.plugins.filter(
|
|
|
|
|
(p) => !(p instanceof ForkTsCheckerWebpackPlugin)
|
|
|
|
|
);
|
2020-10-08 08:20:14 +00:00
|
|
|
|
|
|
|
|
|
// copy the options from the original ForkTsCheckerWebpackPlugin
|
|
|
|
|
// instance and add the memoryLimit property
|
|
|
|
|
const forkTsCheckerOptions = existingForkTsChecker.options;
|
|
|
|
|
forkTsCheckerOptions.memoryLimit = process.env.NODE_BUILD_MEMORY || 2048;
|
|
|
|
|
|
|
|
|
|
config.plugins.push(new ForkTsCheckerWebpackPlugin(forkTsCheckerOptions));
|
2021-01-26 15:39:50 +00:00
|
|
|
|
config.plugins.push(
|
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
|
global: "window", // Placeholder for global used in any node_modules
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
config.node.global = false;
|
2020-10-08 08:20:14 +00:00
|
|
|
|
},
|
2020-10-13 18:39:59 +00:00
|
|
|
|
chainWebpack: (config) => {
|
|
|
|
|
// remove the prefetch plugin
|
|
|
|
|
config.plugins.delete("prefetch");
|
|
|
|
|
},
|
|
|
|
|
css: {
|
|
|
|
|
loaderOptions: {
|
|
|
|
|
scss: {
|
|
|
|
|
additionalData: `@import "@/variables.scss";`,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2018-05-18 09:28:29 +00:00
|
|
|
|
};
|