From b9018fdaa1dde7ebfa989e87ba152e0b5ca25c41 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sat, 12 Mar 2022 08:29:26 -0600 Subject: [PATCH] feat: CSS modules --- .../http/src/server/build/http.neutrinorc.js | 9 +++---- packages/http/src/server/index.js | 24 ++++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/packages/http/src/server/build/http.neutrinorc.js b/packages/http/src/server/build/http.neutrinorc.js index 6f16138..e6e5ecc 100644 --- a/packages/http/src/server/build/http.neutrinorc.js +++ b/packages/http/src/server/build/http.neutrinorc.js @@ -38,12 +38,9 @@ module.exports = (async () => { }]); // Entrypoints. const {output: originalOutput} = options; - options.root = root; - config.context(options.root); - options.source = '.'; - options.mains.index = 'entry'; + options.mains.index = join(root, 'entry'); options.mains.tests = { - entry: './client/tests', + entry: join(root, 'client', 'tests'), title: 'Testbed', }; options.output = join(originalOutput, flecks.get('@flecks/http/server.output')); @@ -84,7 +81,7 @@ module.exports = (async () => { .publicPath('/') .filename(isProduction ? 'assets/[name].[contenthash:8].js' : 'assets/[name].js'); config - .devtool(isProduction ? 'source-map' : 'eval-source-map') + .devtool('source-map') .target('web'); config.node .set('Buffer', true) diff --git a/packages/http/src/server/index.js b/packages/http/src/server/index.js index b8df037..8f11f1c 100644 --- a/packages/http/src/server/index.js +++ b/packages/http/src/server/index.js @@ -12,14 +12,22 @@ const debug = D('@flecks/http/server'); export default { [Hooks]: { '@flecks/core.build': (target, config) => { - config.use.push(styleLoader({ - extract: { - enabled: false, - }, - style: { - injectType: 'lazyStyleTag', - }, - })); + config.use.push((neutrino) => { + const isProduction = 'production' === neutrino.config.get('mode'); + neutrino.use( + styleLoader({ + extract: { + enabled: false, + }, + modules: { + localIdentName: isProduction ? '[hash]' : '[path][name]__[local]', + }, + style: { + injectType: 'lazyStyleTag', + }, + }), + ); + }); config.use.push(fontLoader()); config.use.push(imageLoader()); },