Better themeing support!!
This commit is contained in:
@@ -1,13 +1,27 @@
|
||||
// Common configuration for webpacker loaded from config/webpacker.yml
|
||||
|
||||
const { join, resolve } = require('path');
|
||||
const { dirname, join, resolve } = require('path');
|
||||
const { env } = require('process');
|
||||
const { safeLoad } = require('js-yaml');
|
||||
const { readFileSync } = require('fs');
|
||||
const glob = require('glob');
|
||||
|
||||
const configPath = resolve('config', 'webpacker.yml');
|
||||
const loadersDir = join(__dirname, 'loaders');
|
||||
const settings = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV];
|
||||
const themeFiles = glob.sync('app/javascript/themes/*/theme.yml');
|
||||
const themes = {};
|
||||
|
||||
for (let i = 0; i < themeFiles.length; i++) {
|
||||
const themeFile = themeFiles[i];
|
||||
const data = safeLoad(readFileSync(themeFile), 'utf8');
|
||||
if (!data.pack_directory) {
|
||||
data.pack_directory = dirname(themeFile);
|
||||
}
|
||||
if (data.name && data.pack) {
|
||||
themes[data.name] = data;
|
||||
}
|
||||
}
|
||||
|
||||
function removeOuterSlashes(string) {
|
||||
return string.replace(/^\/*/, '').replace(/\/*$/, '');
|
||||
@@ -29,6 +43,7 @@ const output = {
|
||||
|
||||
module.exports = {
|
||||
settings,
|
||||
themes,
|
||||
env,
|
||||
loadersDir,
|
||||
output,
|
||||
|
Reference in New Issue
Block a user