open-index/open-npm huggingface dataset:
npm package: @nujabesloo/shader-loader
Description: A Webpack loader to import GLSL/WGSL shaders as strings with optional compression
Author: nujabesloo
Latest version: 1.0.0

# @nujabesloo/shader-loader
A simple Webpack loader for single shader files (`.glsl` / `.wgsl`). It allows you to import shaders as strings and optionally minify them.

## Installation

```bash
npm i @nujabesloo/shader-loader -D
```

## Usage

```js
// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.(glsl|wgsl)$/,
        use: 'shader-loader' // simple usage
      }
    ]
  }
};
```

## Options

```js
{
  loader: '@nujabesloo/shader-loader',
  options: {
    minify: true // Optional: compress the shader code
  }
}
```

When `minify` enabled, the shader code will be compressed by:

- Trimming leading and trailing whitespace

- Removing single-line (// ...) and multi-line (/* ... */) comments

- Preserving necessary line breaks (\n) for GLSL/WGSL syntax

- Merging multiple consecutive spaces into a single space


## Example Webpack Configuration
```js
const path = require('path');
module.exports = {
    mode: 'development',
    devtool: 'source-map',
    entry: './src/index.js',
    context: __dirname,
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js',
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                type: 'javascript/esm', // !!!
                use: {
                    loader: 'babel-loader'
                }
            },
            {
                test: /\.(glsl|wgsl)$/,
                use: {
                    loader: '@nujabesloo/shader-loader',
                    options: {
                        minify: true, // default is false
                    }
                },
            },
        ],
    },
};
```