0.3.4 • Published 3 years ago

webpack-free-tex-packer v0.3.4

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

webpack-free-tex-packer

Stats \ Webpack Free texture packer plugin \ Based on https://github.com/odrick/free-tex-packer

Install

$ npm install webpack-free-tex-packer

Basic usage

webpack.config.js

const path = require('path');
const WebpackFreeTexPacker = require('webpack-free-tex-packer');

module.exports = {
    entry: [
        './src/index',
        'webpack-dev-server/client?http://localhost:8080'
    ],
    output: {filename: 'index.js'},
    mode: 'development',
    plugins: [
        new WebpackFreeTexPacker(path.resolve(__dirname, 'atlases'))
    ]
};

Output:

http://localhost:8080/pack-result.png \ http://localhost:8080/pack-result.json

Advanced usage

Use packer options object, multiple sources, custom output folder

webpack.config.js

const path = require('path');
const WebpackFreeTexPacker = require('webpack-free-tex-packer');

let sources = [];
sources.push(path.resolve(__dirname, 'atlases/10.png'));
sources.push(path.resolve(__dirname, 'atlases/11.png'));
sources.push(path.resolve(__dirname, 'atlases/12.png'));
sources.push(path.resolve(__dirname, 'atlases/dir1'));
sources.push(path.resolve(__dirname, 'atlases/dir2/.'));

let packOptions = {
    textureName: 'atlas',
    width: 512,
    height: 512,
    fixedSize: false,
    padding: 2,
    allowRotation: true,
    detectIdentical: true,
    allowTrim: true,
    exporter: "Pixi",
    removeFileExtension: false,
    prependFolderName: true
};

module.exports = {
    entry: [
        './src/index',
        'webpack-dev-server/client?http://localhost:8080'
    ],
    output: {filename: 'index.js'},
    mode: 'development',
    plugins: [
        new WebpackFreeTexPacker(sources, 'assets', packOptions)
    ]
};

Output:

http://localhost:8080/assets/atlas.png \ http://localhost:8080/assets/atlas.json


Plugin arguments

proptypedescription
sourcesString or ArrayImages or folders path. Folder path, ended by ('.', '*' or '*.*') includes images to atlas root.
outputStringOutput folder
packOptionsObjectPack options

Full example

https://github.com/odrick/webpack-free-tex-packer/tree/master/example


Pack options description: https://github.com/odrick/free-tex-packer-core#available-options

Custom exporters description: https://github.com/odrick/free-tex-packer-core#custom-exporter

Used libs


License: MIT

0.3.2

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago