feat: auto styles

This commit is contained in:
cha0s 2021-01-26 23:25:13 -06:00
parent c014384712
commit 214b62d411

View File

@ -1,7 +1,6 @@
const {basename, dirname, extname, join} = require('path');
const airbnb = require('@neutrinojs/airbnb');
const banner = require('@neutrinojs/banner');
const glob = require('glob');
const mocha = require('@neutrinojs/mocha');
const react = require('@neutrinojs/react');
@ -17,10 +16,7 @@ module.exports = {
},
}),
(neutrino) => {
const {
files = [],
name,
} = neutrino.options.packageJson;
const {files = [], name} = neutrino.options.packageJson;
files
.filter((file) => {
const {source} = neutrino.options;
@ -49,9 +45,37 @@ module.exports = {
const testEntry = neutrino.config.entry('test').clear();
testPaths.forEach((path) => testEntry.add(path));
}
const cssPaths = glob.sync('./src/**/*.{css,scss}');
if (cssPaths.length > 0) {
const cssEntry = neutrino.config.entry('index.css').clear();
cssPaths.forEach((path) => cssEntry.add(path));
}
neutrino.options.output = '.';
react({
clean: false,
hot: false,
style: {
extract: {
enabled: false,
},
test: /\.(css|sass|scss)$/,
modulesTest: /\.module\.(css|sass|scss)$/,
loaders: [
{
loader: 'postcss-loader',
useId: 'postcss',
options: {
config: {
path: process.cwd(),
},
},
},
{
loader: 'sass-loader',
useId: 'sass',
},
],
},
})(neutrino);
Object.keys(neutrino.options.mains).forEach((main) => {
neutrino.config.plugins.delete(`html-${main}`);
@ -71,17 +95,13 @@ module.exports = {
.end()
.node
.set('__dirname', false)
.set('__filename', false)
.set('process', 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({
allowlist: ['uuid'],
importType: 'umd',
}));
neutrino.config.externals(nodeExternals({importType: 'umd'}));
},
mocha(),
],