Coder Social home page Coder Social logo

nwjs-webpack-hot-loader's Introduction

nwjs + webpack代码热更新

webpack在nwjs环境下的简单的代码热更新实现。

使用方法

使用loader加载器,在html或pug中注入js代码

// html的loader配置
{
  test: /^.*\.html$/,
  use: ['html-loader', {
    loader: engineering,
    options: {
      buildFile: './build',
      rootFile: 'app.js',
      type: 'html'
    }
  }]
},
// pug or jade的loader配置
{
  test: /^.*\.pug$/,
  use: ['pug-loader', {
    loader: engineering,
    options: {
      buildFile: './build',
      rootFile: 'app.js',
      type: 'pug'
    }
  }]
}

手动引入js脚本

<script src="/path/to/node_modules/nwjs-webpack-hot-loader/lib/hot-update.js"></script>
<script>
window.addEventListener('load', function __hot_update_load__(event){
  var __update__ = new __NwWebpackHotUpdate__(
    './build', // buildFile
    'app.js'   // rootFile
  );
  __update__.init();
}, false);
</script>

参数

  • buildFile: webpack文件编译后的目录
  • rootFile: webpack入口文件名称
  • type: 【loader】文件类型,可以是html、pug、jade

nwjs-webpack-hot-loader's People

Contributors

duan602728596 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.