const path = require('path'); const react = require('@neutrinojs/react'); const styles = require('@neutrinojs/style-loader'); const globImporter = require('node-sass-glob-importer'); const {DefinePlugin} = require('webpack'); const {afterPlatform, initial} = require('./middleware'); module.exports = { options: { root: __dirname, }, use: [ initial({ environmentDefines: ['FRONTEND_ORIGIN'], scwpPaths: [/^@avocado/], }), 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({ babelPaths: [/^@avocado/, /^contempo/, /^scwp/], }), (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, }, ]); } ], };