finished webpack config for switching themes

This commit is contained in:
lotte
2019-04-19 16:44:57 +02:00
committed by Art Lowel
parent 22928c3f23
commit 8a32777802
111 changed files with 249 additions and 455 deletions

View File

@@ -6,11 +6,12 @@ const {
} = require('./helpers');
// const theme = '';
// const themeFolder = '';
const theme = 'mantis';
const themeFolder = 'themes';
const globalCSSImports = [
path.resolve(__dirname, '..', 'src/styles/_variables.scss'),
path.resolve(__dirname, '..', 'src/styles/_mixins.scss'),
];
const themeReplaceOptions =
{
multiple: [
@@ -21,17 +22,17 @@ const themeReplaceOptions =
},
{
search: '$themePath$/',
replace: themeFolder + (themeFolder.length ? '/' : ''),
replace: (theme.length ? 'themes/' : ''),
},
{
search: '$theme$.',
replace: theme + (theme.length ? '.' : ''),
replace: (theme.length ? theme + '.' : ''),
},
{
search: '$themePath$/',
replace: themeFolder + (themeFolder.length ? '/' : ''),
replace: (theme.length ? 'themes/' : ''),
}
]
};
@@ -58,28 +59,6 @@ module.exports = {
loader: 'string-replace-loader',
options: themeReplaceOptions
},
{
test: /styles\/_variables_imports.scss$/,
enforce: 'pre',
use: [
'debug-loader',
{
loader: 'string-replace-loader',
options: themeReplaceOptions
},
]
},
{
test: /\.scss$/,
use: [
{
loader: 'string-replace-loader',
options: themeReplaceOptions
},
]
},
{
test: /\.ts$/,
loader: '@ngtools/webpack'
@@ -113,14 +92,6 @@ module.exports = {
path.resolve(__dirname, '..', 'src/styles/_exposed_variables.scss')
],
use: [
{
loader: 'string-replace-loader',
options:
{
search: 'theme\.',
replace: theme + (theme.length ? '\.' : ''),
}
},
{
loader: 'raw-loader',
options: {
@@ -139,7 +110,16 @@ module.exports = {
sourceMap: true
}
},
'debug-loader',
{
loader: 'string-replace-loader',
options: themeReplaceOptions
},
{
loader: 'sass-resources-loader',
options: {
resources: globalCSSImports
},
},
'webpack-import-glob-loader'
]
},
@@ -150,7 +130,18 @@ module.exports = {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "sass-loader" // compiles Sass to CSS
}]
},
{
loader: 'string-replace-loader',
options: themeReplaceOptions
},
{
loader: 'sass-resources-loader',
options: {
resources: globalCSSImports
},
}
]
},
{
test: /\.html$/,
@@ -168,10 +159,7 @@ module.exports = {
}, {
from: join(__dirname, '..', 'resources', 'i18n'),
to: join('assets', 'i18n')
}, {
from: join(__dirname, '..', 'src', 'styles', '_variables_imports.scss'),
to: join(__dirname, '..', 'src', 'styles', '_variables.scss')
}])
}
])
]
};