Skip to content

supermedium/aframe-super-hot-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aframe-super-hot-loader

Webpack loaders for enabling Hot Module Replacement on A-Frame HTML, components, and shaders.

Live reload A-Frame, components, and shaders. Never refresh the page during development again!

Watch Video

Usage

Installation

npm install --save aframe-super-hot-loader
npm install --save aframe-super-hot-html-loader diff-dom

Webpack Config

There are two separate Webpack loaders, one for JS and one for HTML. In your Webpack config:

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.js/,
        exclude: /(node_modules)/,
        use: ['aframe-super-hot-loader']
      },
      {
        test: /\.html/,
        exclude: /(node_modules)/,
        use: ['aframe-super-hot-html-loader']
      }
    ]
  }
  // ...
}

Dev Server

Then run webpack-dev-server with hot enabled:

webpack-dev-server --hot --inline

or in your Webpack config:

module.exports = {
  devServer: {
    hot: true
  }
};

Requiring

For the HTML loader, you'll need to require an HTML file through Webpack that contains your scene, which will be injected into your index.html.

// index.js
require('./scene.html');

And an example HTML file:

<!-- index.html -->
<html>
  <head>
    <script src="build/build.js"></script>
  </head>
  <body>
    <!-- require('./scene.html') will be injected here from the JS build. -->
  </body>
</html>

Boilerplate Example

There's a boilerplate example in the examples/ directory:

cd examples
npm install
npm run start

Then try it out by modifying files. If you'd like to incorporate into your own project, you can start from that boilerplate base and / or absorb the Webpack configuration.

About

🔥 Webpack loader for hot reloading A-Frame components and shaders.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published