UNPKG

@luxdamore/nuxt-canvas-sketch

Version:

🌈🎨 Generative Art is the idea realized as genetic code of artificial events, as construction of dynamic complex systems able to generate endless variations. This is also a nuxt-module (@luxdamore/nuxt-canvas-sketch) - [three.js, tensorflow.js and gsap a

71 lines (58 loc) • 1.55 kB
import path from 'path'; import * as PACKAGE from '../package.json'; import defaultConfig from './config'; import log from './logger'; // Options const moduleName = 'canvas-sketch' , logger = log( `nuxt:${ moduleName }`, ) ; export default function( moduleOptions, ) { const options = { ... defaultConfig, hideGenericMessagesInConsole: ! this.options.dev, ... moduleOptions || {}, ... this.options[ moduleName ] || {}, ... this.options.canvasSketch || {}, }; this.extendBuild( config => { // FIXME: Check if already exist config.module.rules.push( { test: /\.(glsl|vs|fs|vert|frag)$/, exclude: /(node_modules)/, use: [ 'raw-loader', 'glslify-loader', ], }, { test: /\.(obj)$/, exclude: /(node_modules)/, use: 'webpack-obj-loader', }, ); } ); this.addPlugin( { src: path.resolve( __dirname, 'plugin.client.js' ), mode: 'client', options: options.sketch, } ); ! options.hideGenericMessagesInConsole && logger.info( '\x1B[32m%s\x1B[0m', moduleName, 'canvas-sketch correctly injected', ); } const meta = PACKAGE; export { meta };