From 5791615cb48a1c34337054f21b7615a78579f764 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Wed, 14 Feb 2024 15:16:34 +1300 Subject: [PATCH] Webpack config update. --- webpack.config.js | 44 ++++++++++++-------------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 11ef865..1cefdd3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,12 +1,8 @@ const Path = require('path'); const webpackConfig = require('@silverstripe/webpack-config'); const { - resolveJS, - externalJS, - moduleJS, - pluginJS, - moduleCSS, - pluginCSS, + JavascriptWebpackConfig, + CssWebpackConfig } = webpackConfig; const ENV = process.env.NODE_ENV; @@ -19,34 +15,18 @@ const PATHS = { }; const config = [ - { - name: 'js', - entry: { + // JS bundle + new JavascriptWebpackConfig('js', PATHS, 'silverstripe-versioned-snapshot-admin') + .setEntry({ bundle: `${PATHS.SRC}/bundles/bundle.js`, - }, - output: { - path: PATHS.DIST, - filename: 'js/[name].js', - }, - devtool: (ENV !== 'production') ? 'source-map' : '', - resolve: resolveJS(ENV, PATHS), - externals: externalJS(ENV, PATHS), - module: moduleJS(ENV, PATHS), - plugins: pluginJS(ENV, PATHS), - }, - { - name: 'css', - entry: { + }) + .getConfig(), + // sass to css + new CssWebpackConfig('css', PATHS) + .setEntry({ bundle: `${PATHS.SRC}/styles/bundle.scss`, - }, - output: { - path: PATHS.DIST, - filename: 'styles/[name].css', - }, - devtool: (ENV !== 'production') ? 'source-map' : '', - module: moduleCSS(ENV, PATHS), - plugins: pluginCSS(ENV, PATHS), - }, + }) + .getConfig(), ]; // Use WEBPACK_CHILD=js or WEBPACK_CHILD=css env var to run a single config