Skip to content

theatrejs/loader-ldtk

Repository files navigation

Copyright License Bundle Size (Gzipped) NPM Version

LDTK Webpack Loader

⚙️ A Webpack Loader for LDTK files.

Installation

npm install @theatrejs/plugin-ldtk --save
npm install @theatrejs/loader-ldtk --save-dev

Webpack Configuration

{
    'module': {
        'rules': [
            ...
            {
                'test': /\.ldtk$/,
                'use': [
                    {
                        'loader': '@theatrejs/loader-ldtk'
                    }
                ]
            }
            ...
        ]
    }
}

Webpack Configuration (Advanced Options)

{
    'module': {
        'rules': [
            ...
            {
                'test': /\.ldtk$/,
                'use': [
                    {
                        'loader': '@theatrejs/loader-ldtk',
                        'options': {
                            'constants': true // The option for generating the constants files with all the LDTK level and layer names.
                        }
                    }
                ]
            }
            ...
        ]
    }
}

Quick Start

import ldtk from './game.ldtk';

import * as LAYERS_GAME from './layers.game.ldtk';
import * as LEVELS_GAME from './levels.game.ldtk';

const grid = ldtk.createGrid({
    $level: LEVELS_GAME.PROTOTYPE,
    $layer: LAYERS_GAME.ACTORS
});