kraftvaerk / generator-rammevaerk

Scaffold a web project in kraftvaerk style
MIT License
5 stars 4 forks source link

Make better use of config.js #36

Closed kristoforsalmin closed 6 years ago

kristoforsalmin commented 6 years ago

Hi everyone,

I'm thinking maybe it'd be nice to extend our config.js, because currently it's only being used for paths.

Idea is to use the config for any options we have, a quick example will explain it better than me:

export default {
    ...

    <NAME_OF_FEATURE>: {
        paths: {
            src: <SRC>,
            dest: <DEST>
        },
        <NAME_OF_FIST_PLUGIN>: <OPTIONS_OF_FIST_PLUGIN>,
        <NAME_OF_N_PLUGIN>: <OPTIONS_OF_N_PLUGIN>
    },

    mockup: {
        paths: {
            dest: `${baseDir}/Mockup`,
            src: `${baseDir}/Mockup`
        },
        pug: {
            data: {
                site: {
                    ...
                }
            },
            pretty: true
        }
    },

    ...
};

One of the benefits I see in this approach is that we're going to improve developer experience by abstracting configuration out of logic, so in most cases you'll only need to change the config a little bit in order to adjust things. Also logic will be more clean as all configuration-related stuff will be removed.

What do you think? πŸ˜„

Thanks

mi2oon commented 6 years ago

@racse1 I like the benefits and as you correctly point this abstraction does have it's shine. However, I actually never really liked the fact of abstracting plugin options anyways and the reason for that is mainly if a developer needs to fiddle around with those option he/she should have a better understanding of the logic behind it. Therefore having an abstrations only servers as a black box which I would like to avoid. What do you think about that?

kristoforsalmin commented 6 years ago

@mi2oon Yeah... I didn't think about that, so a developer would actually have to dig in and learn what's going on there, agreed πŸ‘ However I still like the idea of unifying filenames and tasks, but that's a separate matter, if it makes sense at all πŸ˜„

mi2oon commented 6 years ago

@racse1 I totally agree to that 😁