Add support for resources in themes

This commit is contained in:
Art Lowel
2019-06-06 10:30:24 +02:00
parent 99ca2dedea
commit 25edc3c952

View File

@@ -1,18 +1,41 @@
const CopyWebpackPlugin = require('copy-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path'); const path = require('path');
const fs = require('fs');
const { const {
projectRoot, projectRoot,
buildRoot, buildRoot,
globalCSSImports, globalCSSImports,
theme,
themePath, themePath,
themedTest, themedTest,
themedUse themedUse
} = require('./helpers'); } = require('./helpers');
module.exports = (env) => { module.exports = (env) => {
return { let copyWebpackOptions = [{
mode: 'development', from: path.join(__dirname, '..', 'node_modules', '@fortawesome', 'fontawesome-free', 'webfonts'),
devtool: 'source-map', 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: { resolve: {
extensions: ['.ts', '.js', '.json'] extensions: ['.ts', '.js', '.json']
}, },
@@ -144,17 +167,7 @@ module.exports = (env) => {
] ]
}, },
plugins: [ plugins: [
new CopyWebpackPlugin([{ new CopyWebpackPlugin(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')
}
])
] ]
} }
}; };