mendix / pluggable-widgets-tools

Moved to widget resources:
https://github.com/mendix/widgets-resources/
Apache License 2.0
8 stars 5 forks source link

Pluggable Widgets Tools

npm version Mendix 8 Build Status npm GitHub release GitHub issues

About

Library to build, test, format, run, release and lint your Pluggable Widget

How to install

Install from npm using npm install @mendix/pluggable-widgets-tools

How to use

In your package.json tasks, use the following command with the desired task: pluggable-widgets-tools task

Available tasks

Examples

"start": "pluggable-widgets-tools start:server --open"

"build": "pluggable-widgets-tools build:js"

"lint": "pluggable-widgets-tools lint"

"lint:fix": "pluggable-widgets-tools lint:fix"

"test:unit": "pluggable-widgets-tools test:unit --coverage"

Notes

If you are using mono repositories and need to build multiples widgets using Lerna or some other tool, you can provide the option --subprojectPath for the tasks build, start and release.

If you are using a different folder for your Mendix project (for example, you are developing a widget on Mac OS, but your project is on Windows in Parallels), you can use the environment variable MX_PROJECT_PATH to specifiy this. This can either be set when executing the build command, or added to a .env file to your widget root directory containing the path. This should look like this:

MX_PROJECT_PATH="/Volumes/Windows/path/to/your/project"

Webpack extensibility

To extend the current webpack configurations and add your own custom features, you can create a file inside the root of your project with the files webpack.config.dev.js or webpack.config.prod.js according to your necessity. To extend the current files you can add inside your custom file the following lines:

Please note we have different configurations for web/hybrid and native mobile apps because native mobile doesn't have a preview mode in Mendix Studio Pro. Your preview configuration is related to the file Widget.webmodeler.tsx or .jsx.

For web and hybrid mobile apps

const merge = require("webpack-merge");
const baseConfig = require("./node_modules/@mendix/pluggable-widgets-tools/configs/webpack.config.dev.js"); //Can also be webpack.config.prod.js

const customConfig = {
    // Custom configuration goes here
    devtool: "source-map"
};
const previewConfig = {
    // Custom configuration goes here
    devtool: "source-map"
};

module.exports = [merge(baseConfig[0], customConfig), merge(baseConfig[1], previewConfig)];

For native mobile apps

const merge = require("webpack-merge");
const baseConfig = require("./node_modules/@mendix/pluggable-widgets-tools/configs/webpack.native.config.js");

const customConfig = {
    // Custom configuration goes here
    devtool: "source-map"
};

module.exports = [merge(baseConfig[0], customConfig)];