py-loader

Webpack loader for Python

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
py-loader
4760.3.15 years ago5 years agoMinified + gzip package size for py-loader in KB

Readme

src="https://cdn.worldvectorlogo.com/logos/python-5.svg">
<img width="200" height="200" hspace="20"
  src="https://webpack.js.org/assets/icon-square-big.svg">
Python Webpack Loader

Loads Python files and transpile to JavaScript using the awesome Transcrypt, Jiphy or Javascripthon compilers.

Install

pip install transcrypt  # or jiphy, or javascripthon
npm install --save-dev py-loader

You may specify jiphy instead of transcrypt if you prefer. In this case, ensure that options.compiler in webpack.config.js is set to jiphy (see below). The compiler option for Javascripthon is pj.

Usage

import Something from 'main.py';

Configuration

webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.py$/,
        loader: 'py-loader',
        options: {
          compiler: 'transcrypt'
        }
      }
    ]
  }
}

Extend

py-loader can be extended to use other Python compilers. Just fork this repo and extend the compilers object in index.js.
Please submit a pull request with your addition.

Contributors

  • Ryan Liao (https://github.com/pirsquare)
  • Sebastian Silva (https://github.com/icarito)