Skip to content

deinstapel/environment-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

environment-loader

This is a loader for webpack to be able to load dynamic configurations. The goal is, that you can replace the "bundled" configuration with your own in your deployment. This allows you to use the same container for different deployments without rebuilding the entire applications with different environment variables.

Usage

webpack.config.js

module.exports = {
    module: {
        rules: [
            {
                test: /environment\.(json)$/,
                type: 'javascript/auto',
                use: [
                    '@deinstapel/environment-loader',
                    {
                        loader: 'file-loader',
                        options: {
                            outputPath: '/config/',
                            name: '[name].[ext]',
                        }
                    }
                ]
            }
        ]
    }
}
   
import environment from "../config/environment.json"

environment.then((env) => {
    // Environment can be used  
})

How it works

The file-loader places the file in the build directory to /config/environment.json and passes module.exports = /config/environment.json to the @deinstapel/environment-loader, which parses and loads the url and return a promise, which can be evaluated by the user later on.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published