2020-06-17 11:01:01 -05:00
|
|
|
const path = require('path');
|
|
|
|
const react = require('@neutrinojs/react');
|
|
|
|
const styles = require('@neutrinojs/style-loader');
|
|
|
|
const globImporter = require('node-sass-glob-importer');
|
2020-06-18 07:52:38 -05:00
|
|
|
const scwp = require('scwp/neutrino');
|
2020-06-17 11:01:01 -05:00
|
|
|
const {DefinePlugin} = require('webpack');
|
|
|
|
|
|
|
|
const {afterPlatform, initial} = require('./middleware');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
options: {
|
|
|
|
root: __dirname,
|
|
|
|
},
|
|
|
|
use: [
|
|
|
|
initial({
|
|
|
|
environmentDefines: ['FRONTEND_ORIGIN'],
|
2020-06-18 07:52:38 -05:00
|
|
|
rawScwpPaths: [
|
|
|
|
`${__dirname}/../humus/src/common`,
|
|
|
|
`${__dirname}/../humus/src/server`,
|
|
|
|
],
|
|
|
|
scwpPaths: [
|
|
|
|
/^@avocado/,
|
|
|
|
],
|
2020-06-17 11:01:01 -05:00
|
|
|
}),
|
|
|
|
react({
|
|
|
|
devServer: {
|
|
|
|
contentBase: path.resolve(__dirname, 'resource'),
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
test: /\.(css|sass|scss)$/,
|
|
|
|
modulesTest: /\.module\.(css|sass|scss)$/,
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
useId: 'postcss',
|
|
|
|
options: {
|
|
|
|
config: {
|
|
|
|
path: __dirname,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
useId: 'sass',
|
|
|
|
options: {
|
|
|
|
importer: globImporter(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
html: {
|
|
|
|
template: `${__dirname}/src/client/index.ejs`,
|
|
|
|
title: 'Persea',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
afterPlatform({
|
2020-06-18 07:52:38 -05:00
|
|
|
babelPaths: [
|
|
|
|
/^@avocado/,
|
|
|
|
`${__dirname}/../humus/src/common`,
|
|
|
|
`${__dirname}/../humus/src/server`,
|
|
|
|
],
|
2020-06-17 11:01:01 -05:00
|
|
|
}),
|
|
|
|
(neutrino) => {
|
|
|
|
neutrino.config.module.rule('style')
|
|
|
|
.oneOf('raw')
|
|
|
|
.before('normal')
|
|
|
|
.test(/\.raw\.(css|sass|scss)$/)
|
|
|
|
.use('raw')
|
|
|
|
.loader('raw-loader')
|
|
|
|
.end()
|
|
|
|
.use('postcss')
|
|
|
|
.loader('postcss-loader')
|
|
|
|
.options({config: {path: __dirname}})
|
|
|
|
.end()
|
|
|
|
.use('sass')
|
|
|
|
.loader('sass-loader')
|
|
|
|
.options({importer: globImporter()})
|
|
|
|
.end()
|
|
|
|
neutrino.config.resolve.modules
|
|
|
|
.add(`${neutrino.options.source}/client/scss`);
|
|
|
|
neutrino.config
|
|
|
|
.plugin('avocado-define')
|
|
|
|
.use(DefinePlugin, [
|
|
|
|
{
|
|
|
|
AVOCADO_CLIENT: true,
|
|
|
|
AVOCADO_SERVER: false,
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
],
|
|
|
|
};
|