diff --git a/package.json b/package.json index 6052b1e95e..344448ee23 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "compression": "1.7.1", "cookie-parser": "1.4.3", "core-js": "^2.5.7", + "debug-loader": "^0.0.1", "express": "4.16.2", "express-session": "1.15.6", "fast-json-patch": "^2.0.7", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index c1de58819e..072ba20206 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -24,6 +24,7 @@ import { isAuthenticated } from './core/auth/selectors'; import { AuthService } from './core/auth/auth.service'; import { Angulartics2GoogleAnalytics } from 'angulartics2/ga'; import { RouteService } from './shared/services/route.service'; +import global from '../styles/_variables.scss'; import variables from '../styles/_exposed_variables.scss'; import { CSSVariableService } from './shared/sass-helper/sass-helper.service'; import { MenuService } from './shared/menu/menu.service'; @@ -48,7 +49,7 @@ export class AppComponent implements OnInit, AfterViewInit { slideSidebarOver: Observable; collapsedSidebarWidth: Observable; totalSidebarWidth: Observable; - theme: Observable= of({} as any); + theme: Observable = of({} as any); constructor( @Inject(GLOBAL_CONFIG) public config: GlobalConfig, @@ -64,7 +65,7 @@ export class AppComponent implements OnInit, AfterViewInit { private menuService: MenuService, private windowService: HostWindowService, ) { - + console.log(global); // Load all the languages that are defined as active from the config file translate.addLangs(config.languages.filter((LangConfig) => LangConfig.active === true).map((a) => a.code)); diff --git a/src/styles/_variables.scss b/src/styles/_variables_imports.scss similarity index 100% rename from src/styles/_variables.scss rename to src/styles/_variables_imports.scss diff --git a/webpack/webpack.common.js b/webpack/webpack.common.js index 86c10ba7e3..71312f9bf7 100644 --- a/webpack/webpack.common.js +++ b/webpack/webpack.common.js @@ -5,10 +5,10 @@ const { join } = require('./helpers'); -const theme = ''; -const themeFolder = ''; -// const theme = 'mantis'; -// const themeFolder = 'themes'; +// const theme = ''; +// const themeFolder = ''; +const theme = 'mantis'; +const themeFolder = 'themes'; const themeReplaceOptions = @@ -16,12 +16,24 @@ const themeReplaceOptions = multiple: [ { search: '$theme$.', - replace: theme + (themeFolder.length ? '.' : '') + replace: theme + (theme.length ? '.' : ''), + }, { search: '$themePath$/', - replace: themeFolder + (themeFolder.length ? '/' : '') - }] + replace: themeFolder + (themeFolder.length ? '/' : ''), + + }, + { + search: '$theme$.', + replace: theme + (theme.length ? '.' : ''), + + }, + { + search: '$themePath$/', + replace: themeFolder + (themeFolder.length ? '/' : ''), + } + ] }; module.exports = { mode: 'development', @@ -46,11 +58,28 @@ module.exports = { loader: 'string-replace-loader', options: themeReplaceOptions }, - // { - // test: /styles\/_variables.scss$/, - // 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' @@ -85,11 +114,14 @@ module.exports = { ], use: [ { - loader: 'to-string-loader', - options: { - sourceMap: true - } - }, { + loader: 'string-replace-loader', + options: + { + search: 'theme\.', + replace: theme + (theme.length ? '\.' : ''), + } + }, + { loader: 'raw-loader', options: { sourceMap: true @@ -107,6 +139,7 @@ module.exports = { sourceMap: true } }, + 'debug-loader', 'webpack-import-glob-loader' ] }, @@ -135,6 +168,9 @@ 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') }]) ] diff --git a/yarn.lock b/yarn.lock index 42bfd33486..785f15fb1f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2812,6 +2812,12 @@ dateformat@^1.0.11, dateformat@^1.0.6: get-stdin "^4.0.1" meow "^3.3.0" +debug-loader@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/debug-loader/-/debug-loader-0.0.1.tgz#44dc37e09e3c39e6af334681960f70a534a9d056" + dependencies: + loader-utils "^0.2.12" + debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.6, debug@^2.6.8: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -5853,7 +5859,7 @@ loader-runner@^2.3.0: resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2" integrity sha1-9IKuqC1UPgeSFwDVpG7yb9rGuKI= -loader-utils@^0.2.15, loader-utils@^0.2.16: +loader-utils@^0.2.12, loader-utils@^0.2.15, loader-utils@^0.2.16: version "0.2.17" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" integrity sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g=