Add support for dynamic themes

This commit is contained in:
Art Lowel
2021-02-25 15:04:32 +01:00
parent 70dac6bc8f
commit 5a6e4b1278
224 changed files with 3429 additions and 1017 deletions

View File

@@ -1,4 +1,4 @@
import { buildRoot, globalCSSImports, projectRoot, themedTest, themedUse, themePath } from './helpers';
import { globalCSSImports, projectRoot } from './helpers';
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
@@ -26,11 +26,27 @@ export const copyWebpackOptions = [
}
];
const SCSS_LOADERS = [{
loader: 'postcss-loader',
options: {
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
sassOptions: {
includePaths: [projectRoot('./')]
}
}
},]
export const commonExports = {
plugins: [
new CopyWebpackPlugin(copyWebpackOptions),
new HtmlWebpackPlugin({
template: buildRoot('./index.html', ),
template: projectRoot('./src/index.html', ),
output: projectRoot('dist'),
inject: 'head'
}),
@@ -40,14 +56,6 @@ export const commonExports = {
],
module: {
rules: [
{
test: (filePath) => themedTest(filePath, 'scss'),
use: (info) => themedUse(info.resource, 'scss')
},
{
test: (filePath) => themedTest(filePath, 'html'),
use: (info) => themedUse(info.resource, 'html')
},
{
test: /\.ts$/,
loader: '@ngtools/webpack'
@@ -56,19 +64,10 @@ export const commonExports = {
test: /\.scss$/,
exclude: [
/node_modules/,
buildRoot('styles/_exposed_variables.scss'),
buildRoot('styles/_variables.scss')
/(_exposed)?_variables.scss$|\/src\/themes\/[^/]+\/styles\/.+.scss$/
],
use: [
{
loader: 'sass-loader',
options: {
sourceMap: true,
sassOptions: {
includePaths: [projectRoot('./'), path.join(themePath, 'styles')]
}
}
},
...SCSS_LOADERS,
{
loader: 'sass-resources-loader',
options: {
@@ -78,24 +77,10 @@ export const commonExports = {
]
},
{
test: /(_exposed)?_variables.scss$/,
test: /(_exposed)?_variables.scss$|\/src\/themes\/[^/]+\/styles\/.+.scss$/,
exclude: [/node_modules/],
use: [
{
loader: 'postcss-loader',
options: {
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
sassOptions: {
includePaths: [projectRoot('./'), path.join(themePath, 'styles')]
}
}
}
...SCSS_LOADERS,
]
},
],