oyster/lending/craco.config.js

57 lines
1.6 KiB
JavaScript
Raw Normal View History

const CracoLessPlugin = require('craco-less');
2021-02-08 12:48:07 -08:00
const CracoAlias = require('craco-alias');
const CracoBabelLoader = require('craco-babel-loader');
const path = require('path');
const fs = require('fs');
//console.log('qualified', pnp.resolveRequest('@babel/preset-typescript'), path.resolve(__dirname, '/') + 'src/');
// Handle relative paths to sibling packages
const appDirectory = fs.realpathSync(process.cwd());
const resolvePackage = (relativePath) => path.resolve(appDirectory, relativePath);
2020-11-16 20:59:53 -08:00
module.exports = {
2021-02-08 12:48:07 -08:00
webpack: {
configure: (webpackConfig) => {
const scopePluginIndex = webpackConfig.resolve.plugins.findIndex(
({ constructor }) => constructor && constructor.name === 'ModuleScopePlugin'
);
webpackConfig.resolve.plugins.splice(scopePluginIndex, 1);
return webpackConfig;
},
},
2020-11-16 20:59:53 -08:00
plugins: [
2021-02-08 12:48:07 -08:00
{
plugin: CracoBabelLoader,
options: {
includes: [
// No "unexpected token" error importing components from these lerna siblings:
resolvePackage('../packages'),
],
},
},
{
plugin: CracoAlias,
options: {
source: 'tsconfig',
// baseUrl SHOULD be specified
// plugin does not take it from tsconfig
baseUrl: '../',
// tsConfigPath should point to the file where "baseUrl" and "paths" are specified
tsConfigPath: '../tsconfig.base.json',
},
},
2020-11-16 20:59:53 -08:00
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: { '@primary-color': '#2abdd2' },
2020-11-16 20:59:53 -08:00
javascriptEnabled: true,
},
},
},
},
],
};