From 25edc3c952c05cb7d65e1ab35cdf4bd91c3085cb Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Thu, 6 Jun 2019 10:30:24 +0200 Subject: [PATCH] Add support for resources in themes --- webpack/webpack.common.js | 41 ++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/webpack/webpack.common.js b/webpack/webpack.common.js index 5177984c61..028815d958 100644 --- a/webpack/webpack.common.js +++ b/webpack/webpack.common.js @@ -1,18 +1,41 @@ const CopyWebpackPlugin = require('copy-webpack-plugin'); const path = require('path'); +const fs = require('fs'); const { projectRoot, buildRoot, globalCSSImports, + theme, themePath, themedTest, themedUse } = require('./helpers'); module.exports = (env) => { - return { - mode: 'development', - devtool: 'source-map', + let copyWebpackOptions = [{ + from: path.join(__dirname, '..', 'node_modules', '@fortawesome', 'fontawesome-free', 'webfonts'), + to: path.join('assets', 'fonts') + }, { + from: path.join(__dirname, '..', 'resources', 'images'), + to: path.join('assets', 'images') + }, { + from: path.join(__dirname, '..', 'resources', 'i18n'), + to: path.join('assets', 'i18n') + } + ]; + + const themeImages = path.join(themePath, 'resources', 'images'); + if(theme && fs.existsSync(themeImages)) { + copyWebpackOptions.push({ + from: themeImages, + to: path.join('assets', 'images') , + force: true, + }); + } + + return { + mode: 'development', + devtool: 'source-map', resolve: { extensions: ['.ts', '.js', '.json'] }, @@ -144,17 +167,7 @@ module.exports = (env) => { ] }, plugins: [ - new CopyWebpackPlugin([{ - from: path.join(__dirname, '..', 'node_modules', '@fortawesome', 'fontawesome-free', 'webfonts'), - to: path.join('assets', 'fonts') - }, { - from: path.join(__dirname, '..', 'resources', 'images'), - to: path.join('assets', 'images') - }, { - from: path.join(__dirname, '..', 'resources', 'i18n'), - to: path.join('assets', 'i18n') - } - ]) + new CopyWebpackPlugin(copyWebpackOptions) ] } };