latus/config/.neutrinorc.js

67 lines
1.9 KiB
JavaScript
Raw Normal View History

2020-12-27 19:16:29 -06:00
const {basename, dirname, extname, join} = require('path');
2020-11-30 06:28:29 -06:00
const airbnbBase = require('@neutrinojs/airbnb-base');
const mocha = require('@neutrinojs/mocha');
2020-12-24 23:11:47 -06:00
const react = require('@neutrinojs/react');
2020-12-24 19:56:09 -06:00
const nodeExternals = require('webpack-node-externals');
2020-11-30 06:28:29 -06:00
2020-12-24 23:11:47 -06:00
module.exports = {
2020-12-02 16:34:52 -06:00
options: {},
2020-11-30 06:28:29 -06:00
use: [
airbnbBase({
eslint: {
cache: false,
baseConfig: require(`${__dirname}/.eslint.defaults`),
},
}),
(neutrino) => {
2020-12-27 19:16:29 -06:00
const {files = [], name} = neutrino.options.packageJson;
2020-12-24 23:11:47 -06:00
files
.filter((file) => {
try {
require.resolve(`${neutrino.options.source}/${file}`);
return true;
}
catch (error) {
return false;
}
})
.forEach((file) => {
2020-12-27 19:16:29 -06:00
const isIndex = 'index.js' === file;
const trimmed = join(dirname(file), basename(file, extname(file)));
neutrino.options.mains[trimmed] = {entry: isIndex ? file : `./src/${trimmed}`};
2020-12-24 23:11:47 -06:00
});
neutrino.options.output = '.';
react({
2020-11-30 06:28:29 -06:00
clean: false,
})(neutrino);
2020-12-24 23:11:47 -06:00
Object.keys(neutrino.options.mains).forEach((main) => {
neutrino.config.plugins.delete(`html-${main}`);
});
neutrino.config
.devtool('source-map')
.target('node')
.optimization
.splitChunks(false)
.runtimeChunk(false)
.end()
.output
.filename('[name].js')
.library(name)
.libraryTarget('umd')
.umdNamedDefine(true)
.end()
.node
.set('__dirname', false)
.set('__filename', false);
2020-11-30 06:28:29 -06:00
const options = neutrino.config.module
.rule('compile')
.use('babel')
.get('options');
options.presets[0][1].targets = {esmodules: true};
2020-12-24 19:56:09 -06:00
neutrino.config.externals(nodeExternals({importType: 'umd'}));
2020-11-30 06:28:29 -06:00
},
mocha(),
],
2020-12-24 23:11:47 -06:00
};