nuxt-typo3-config

1.3.0 • Public • Published

Nuxt-TYPO3 configuration loader

Setup your nuxt-typo3 application with .env, .json or TYPO3 API.

Create .env file

Create your .env file

mkdir config
touch config/.env.stage

Run build with selected config file

It runs building process with .env.stage file

ENV_CONFIG=stage yarn build

Initial config

To configure TYPO3 multisites we can fetch initialConfig from TYPO3 API. You have to specify endpoint to get specific configuration:

.env.test:

#### NUXT-TYPO3 #######################################
#
# Connect to TYPO3 backend by API host
#
TYPO3_CONFIG_API=https://typo3instance.com/api?type=835
#
#######################################################

You can mockup initialConfig by json file - for example - env.test.json is the file for local environment.

{
    "typo3": {
      "domains": [
        {
          "name": "localhost",
          "baseURL": "https://www.mydomain.com",
          "api": {
            "baseURL": "https://api.mydomain.com"
          },
          "layouts": {
            "blank-page": "blank-page"
          },
          "i18n": {
            "defaultLocale": "uk"
          }
        }
  
      ]
    }
  }

Setup Nuxt app

loadConfiguration(config, dir)

Read .env files + .json with multidomains configuration

config - configuration key (for .env.production key will be "production", default: "production")

dir - your configuration directory (default: "config")

import loadConfiguration from 'nuxt-typo3-config'
const env = loadConfiguration()

export default {
    ...
    typo3: env.typo3
    ...
}

async getConfiguration(config, dir)

Read .env files and get configuration from API. To get configuration you have to specify TYPO3 endpoint by variable:

TYPO3_CONFIG_API=https://yourtypo3.com/?type=835

config - configuration key (for .env.production key will be "production", default: "production")

dir - your configuration directory (default: "config")

import { getConfiguration } from 'nuxt-typo3-config'

setupConfig = (env) => ({
    ...
    typo3: env.typo3
    ...
})

export default async () => {
  const env = await getConfiguration()

  return setupConfig(env)
}

Readme

Keywords

none

Package Sidebar

Install

npm i nuxt-typo3-config

Weekly Downloads

106

Version

1.3.0

License

MIT

Unpacked Size

8.29 kB

Total Files

10

Last publish

Collaborators

  • mercs600