Skip to content

imyelo/jsbox-webpack-plugin

Repository files navigation

JSBox Webpack Plugin

license npm PRs Welcome

📦 JSBox meets Webpack

Get Started

We have prepared a scaffolding tool (thanks to saojs) for you, to help you start using Webpack to develop JSBox applications more efficiently.

Please ensure that your NPM client is ready, which should be installed with Node.js.

Just run:

mkdir myapp && cd myapp
npx sao sao-jsbox-webpack

Then everything out of the box is ready for you. 🎉

Usage

  1. Set your iPhone's IP (you can find it in JSBox's Setting Tab) into the environment variable JSBOX_HOST.
  2. Run npm start (development mode) / npm run build (production mode) to compiling the codes, and the assembled box file would be sync to your phone automatically while the upload option is turned on.

GLHF 😉

Plugin Usage

const { resolve } = require('path')
const JSBoxPlugin = require('jsbox-webpack-plugin')

module.exports = {
  context: resolve('src'),
  entry: './scripts/main.js',
  output: {
    path: resolve(`dist`),
    filename: 'scripts/main.js',
  },
  plugins: [
    new JSBoxPlugin(/* options */),
  ],
}

Plugin Options

copy

Arguments:

  • copy: [fromPath: string]
  • copy: [{ fromPath: string, toRelativePath: string }]

Default Value: []

Basic Example:

// ...
    new JSBoxPlugin({
      copy: [
        'beta.json',
      ],
    }),
// ...

In case of copying files out of the context:

const { resolve } = require('path')
// ...
    new JSBoxPlugin({
      copy: [
        [resolve(__dirname, 'README.md'), 'README.md],
      ],
    }),
// ...

upload

Arguments:

  • upload: boolean

Default Value: false

Important: Should be used with env variable JSBOX_HOST

Example:

// ...
    new JSBoxPlugin({
      upload: true,
    }),
// ...

and then

JSBOX_HOST=192.168.1.10 npx webpack

uploadTimeout

Arguments:

  • upload: number

Default Value: 10 * 1000 (ms)

Example:

// ...
    new JSBoxPlugin({
      upload: true,
      uploadTimeout: 2 * 1000,
    }),
// ...

Who's using?

License

Apache-2.0 © yelo, 2019 - present