npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

k15t-webpack-build

v2.2.0

Published

Base configuration and utils for building Atlassian Connect apps with webpack

Downloads

55

Readme

About Webpack Build

The project provides a general base configuration for using webpack to build and serve an app UI for Atlassian Connect, e.g. register the atlassian-connect.json in combination with ngrok and additional helper functions.

Installing

$ npm install k15t-webpack-build

Usage

To use the master configuration in your project create a new webpack configuration file e.g. wepack-config.js and add the following lines:

// import build configuration
var build = require('k15t-webpack-build/webpack-build.js');

{
    // setup weback as usual for your project 
    module.exports = master({
        metadata: {
            title: 'Project title'
        },
        entry: {
            'main': './src/main.ts'
        },
        output: {
            path: './target'
        }
    });
}

Add predefined production related plugins

This in includes e.g. a plugin to gather all used licenses and write it to a summary file or to uglify the code. For more details please see the corresponding function in the webpack-build.js

    build.mergeProductionPlugins(commonBuildConfig);

Check third-party licenses building the project

The prod build includes also a license check which gather all used third-party licenses and writes a summery to the root of the output directory. To setup a different output directory you can override metadata.outputlicenseSummaryFile or to define the licenses which must not be used e.g. GPL you can override metadata.notAllowedLicenses = ['GPL']

Atlassian Connect app

In case you're developing an Atlassian Connect app the file addon-descriptor.js helps you to open a HTTPS tunnel and register the app descriptor (atlassian-connect.json) on your dev instance when starting the webpack dev server. The following code will establish an ngrok tunnel that exposes the local port 3000 on your localhost. That ngrok URL is then used to set the descriptor URL in the atlassian-connect.json and then the descriptor is installed to the configured Atlassian Cloud instance :

var webpack = require("webpack");
var WebpackDevServer = require('webpack-dev-server');
var webpackConfig = require('./webpack-common.js');
var HotModuleReplacementPlugin = require('webpack/lib/HotModuleReplacementPlugin');
var addonDescriptor = require('k15t-webpack-build/addon-descriptor');
var rimraf = require('rimraf/rimraf');
var fs = require('fs');

function startServer() {

    var userHome = process.env.HOME || process.env.USERPROFILE;
    var devInstanceAccessInfo = JSON.parse(fs.readFileSync(userHome + '/atlas-cloud-dev.json', 'utf8'));

    addonDescriptor.register(function(addOnBaseUrl) {

        var config = webpackConfig.getBuildConfig(addOnBaseUrl);

        console.log("Clean output directory " + config.output.path);

        rimraf(config.output.path, function(error) {
        });

        console.log("Execute webpack build");

        webpack(config, function(err, stats) {
            if (err) {
                console.log(err);
            } else {

                config.plugins.push(
                    new HotModuleReplacementPlugin()
                );

                console.log("Start webpack development server");

                new WebpackDevServer(webpack(config), {
                    historyApiFallback: false,
                    contentBase: config.output.path,
                    noInfo: false,
                    quiet: false,
                    compress: true,
                    stats: {colors: true},
                    watchOptions: {
                        aggregateTimeout: 300,
                        poll: true
                    }
                }).listen(3000, 'localhost', function(err, result) {
                    if (err) {
                        console.log(err);
                    }
                    console.log('Server started on port 3000');
                });
            }
        });
    }, devInstanceAccessInfo);
}

startServer();

To configure the devInstanceAccessInfo you can use a json file (as above) or use a JS config object directly. The following configuration values are usable:

{
    "baseUrl": "https://myplugin-dev.atlassian.net/wiki",
    "user": "Atlassian-ID-email",
    "password": "secret",
    "ngrok": {
      "region" : "eu",
      "subdomain": "myplugin"
    }
}

where

  • baseUrl identifies the Atlassian cloud instance

  • user and password are the (Atlassian ID) user and password used to install the app descriptor, i.e. they need sufficient permissions in the Atlassian cloud instance. Only if user and password are given will the installation be attempted.

  • ngrok can contain any sensible ngrok configuration passed on to the creation of the ngrok tunnel, see https://www.npmjs.com/package/ngrok#options.

Example scripts which can be added directly to the package.json

"clean:all": "rimraf node_modules target && npm cache clean",
"prepublish": "typings install",
"build": "npm run build:dev",
"build:dev": "devMode=true webpack --progress --config webpack-config.js --profile --colors --display-error-details --display-cached",
"build:prod": "webpack --config webpack-config.js --progress --profile --colors --display-error-details --display-cached",
"start": "npm run server:dev",
"server:dev": "devMode=true node webpack-server-config.js"

To run a script open a console withing the project and enter e.g. npm run build or just npm start

Contribute to this project

If you like to contribute on this project, request a new feature or you find a bug please see CONTRIBUTING.md for further details.

License

Licensed under The MIT License (MIT).