Git Product home page Git Product logo

local-project-sample's Introduction

This is a sample project to setup a local kaluma project.

All local files are from a kaluma cloud project (https://kaluma.io/@niklauslee/internet-clock).

Setup a project folder

Create a project folder with the below files and directories.

my-local-project/
  kaluma_modules/    # third-party modules
  package.json       # project configuration
  index.js           # entry point
  webpack.config.js  # webpack configuration for bundling

Download modules

Download modules in dependencies of package.json from kaluma.io and extract them into kaluma_modules as below folder structure.

Please ensure that you are downloaded the correct version of the module from Releases page for each module project.

kaluma_modules/
  @niklauslee/
    ssd1306-i2c/
    font-minimal/
    esp8266-http-client/
  @kaluma/
    logo-mono/

The downloaded modules could have it's dependencies, so the dependencies should be downloaded and extracted into kaluma_modules recursively.

Setup Webpack

Install webpack and webpack-cli.

$ npm install webpack webpack-cli --save-dev

Don't try npm install. It will try to install all modules in dependencies of package.json from NPM.

Edit webpack.config.js as below:

const path = require('path');

module.exports = {
  mode: 'development',
  entry: './index.js',
  output: {
    filename: 'bundle.js',
    path: __dirname
  },
  resolve: {
    modules: [path.resolve(__dirname, 'kaluma_modules')]
  },
  /* kaluma builtin modules */
  externals: {
    'events': 'commonjs events',
    'gpio': 'commonjs gpio',
    'led': 'commonjs led',
    'button': 'commonjs button',
    'pwm': 'commonjs pwm',
    'adc': 'commonjs adc',
    'i2c': 'commonjs i2c',
    'spi': 'commonjs spi',
    'uart': 'commonjs uart',
    'rp2': 'commonjs rp2',
    'graphics': 'commonjs graphics',
    'at': 'commonjs at',
    'stream': 'commonjs stream',
    'net': 'commonjs net',
    'dgram': 'commonjs dgram',
    'http': 'commonjs http',
    'wifi': 'commonjs wifi',
    'url': 'commonjs url',
  },
  devtool: 'source-map'
};

Bundle

Bundle all files into a single bundle.js file (with a source-map bundlejs.map).

$ npx webpack

Upload

If you installed Kaluma CLI, you can upload the bundled file via serial port.

$ kaluma write bundle.js -p <port>

local-project-sample's People

Contributors

niklauslee avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

tunermod

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.