74 lines
2.1 KiB
JavaScript
74 lines
2.1 KiB
JavaScript
const airbnbBase = require('@neutrinojs/airbnb-base');
|
|
const library = require('@neutrinojs/library');
|
|
const mocha = require('@neutrinojs/mocha');
|
|
const react = require('@neutrinojs/react');
|
|
const nodeExternals = require('webpack-node-externals');
|
|
|
|
module.exports = {
|
|
options: {},
|
|
use: [
|
|
airbnbBase({
|
|
eslint: {
|
|
cache: false,
|
|
baseConfig: require(`${__dirname}/.eslint.defaults`),
|
|
},
|
|
}),
|
|
(neutrino) => {
|
|
const {files, name} = neutrino.options.packageJson;
|
|
files
|
|
.filter((file) => {
|
|
try {
|
|
require.resolve(`${neutrino.options.source}/${file}`);
|
|
return true;
|
|
}
|
|
catch (error) {
|
|
if (file.match(/\.js$/)) {
|
|
try {
|
|
require.resolve(`${neutrino.options.source}/${file.slice(0, -3)}`);
|
|
return true;
|
|
}
|
|
catch (error) {
|
|
return false;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
})
|
|
.map((file) => file.match(/\.js$/) ? file.slice(0, -3) : file)
|
|
.forEach((file) => {
|
|
neutrino.options.mains[file] = {entry: 'index' === file ? file : `./src/${file}`};
|
|
});
|
|
neutrino.options.output = '.';
|
|
react({
|
|
clean: false,
|
|
})(neutrino);
|
|
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);
|
|
const options = neutrino.config.module
|
|
.rule('compile')
|
|
.use('babel')
|
|
.get('options');
|
|
options.presets[0][1].targets = {esmodules: true};
|
|
neutrino.config.externals(nodeExternals({importType: 'umd'}));
|
|
},
|
|
mocha(),
|
|
],
|
|
};
|