Skip to content

About

Webpack plugin that bundles and pushes your AI code to Screeps servers

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Latest commit

 

History

296 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

screeps-webpack-plugin

CI NPM Node version

Bundle and push your AI to Screeps servers!

If you have registered on the official server via Steam or GitHub, please go to account management and make sure you have configured an email and password for your account to access your account on https://screeps.com and https://screeps.com/ptr.

On private servers, make sure you have authorization enabled and that the administrator has created your account.

Installation

npm install screeps-webpack-plugin

The package requires Node.js 24 or later, and loads through both import and require():

import ScreepsWebpackPlugin from 'screeps-webpack-plugin'
const ScreepsWebpackPlugin = require('screeps-webpack-plugin')

Usage

Add the plugin to your Webpack configuration.

Make sure you are using {target: 'node'}, other environments aren't supported. You should have at least one chunk named main in the output.

// webpack.config.js
const path = require('path')
const ScreepsWebpackPlugin = require('screeps-webpack-plugin')

module.exports = {
  target: 'node',
  entry: './index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'main',
    libraryTarget: 'commonjs'
  },
  plugins: [new ScreepsWebpackPlugin(options)]
}

Options

new ScreepsWebpackPlugin({
  branch: '$activeWorld',
  email: 'EMAIL',
  password: 'PASSWORD',
  token: 'TOKEN',
  serverUrl: 'https://screeps.com',
  serverPassword: 'SERVER_PASS',
  gzip: false
})

If your server modules provide support, you can use tokens for authentication and send compressed bundles.

See screeps-modules#Usage for more information.

Hooks

The plugin adds tapable hooks to each compilation, which your own plugins can tap into.

const ScreepsWebpackPlugin = require('screeps-webpack-plugin')

compiler.hooks.compilation.tap('MyPlugin', (compilation) => {
  const hooks = ScreepsWebpackPlugin.getHooks(compilation)

  // ...
})
collectModules

Asynchronously alter the modules which will be pushed to the server.

hooks.collectModules.tapAsync('MyPlugin', ({ modules, plugin, compilation }, cb) => {
  // ...
  cb(null, { modules, plugin, compilation })
})
configureClient

Configure the client used for the request.

hooks.configureClient.tap('MyPlugin', (client, plugin) => {
  // ...
  return client
})
beforeCommit

Inspect request data.

hooks.beforeCommit.tap('MyPlugin', (branch, modules) => {
  // ...
})
afterCommit

Inspect the response body of the commit.

hooks.afterCommit.tap('MyPlugin', (body) => {
  // ...
})

Troubleshooting

The plugin only provides opaque access to the response body, so that it can be safely used in CI. To debug, run with DEBUG=* webpack $ARGS.

Contributing

Share your feedback, bugs and PRs on the issues tracker.

About

Webpack plugin that bundles and pushes your AI code to Screeps servers

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages