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

@trinitymirrordigital/cue-templates-plugin

v2.0.9-alpha.0

Published

Webpack plugin to create cue component yml

Downloads

6

Readme

@trinitymirrordigital/cue-templates-plugin

This sets up a Webpack plug that creates the cue configuration yaml from JS comments

Installation

  yarn add --dev @trinitymirrordigital/cue-templates-plugin

Config

Update your config.yml with the following:

default: &default
 ...

  # Templates plugin
  templates_path: template # folder with web component templates are
  yaml_output: /etc/escenic/cue-web # where the yaml files are outputted in docker image
  start_up_script: /usr/bin/startup.sh # startup script fired when dev-server starts

  ...

Then in webpack config add the following

/* eslint-env node */
const { TemplatePlugin, getFiles } = require('@trinitymirrordigital/cue-templates-plugin');
const { webpackConfig, config } = require('@trinitymirrordigital/webpack-config');
const { merge } = require('webpack-merge');
const { env } = require('process');

// See reach-et-templates-plugin
const files = getFiles(config); // Gets the template files
// Use config data
const {
  cueUrl,
  publicDevOutput,
  publicOutputPath,
  publicRootPath,
  startUpScript,
  yamlOutput,
} = config;

const publicPath = env.NODE_ENV === 'development' ? publicDevOutput : publicOutputPath; // Sets the path depending if using webpack-dev-server or not

// You can pass any webpack config you want that will append to the config please see https://webpack.js.org/
module.exports = merge(webpackConfig, {
  entry: { ...files },
  plugins: [
    // See  reach-et-templates-plugin
    new TemplatePlugin({
      js: publicRootPath, // Sets path to file
      publicPath, // Sets path for output JS
      output: yamlOutput, // sets path for output YAML
      shellScript: startUpScript, // Shell script for webpack dev server see below
    }),
  ],
  new HtmlWebpackPlugin({
      filename: htmlOutput,
      alwaysWriteToDisk: true,
      template: htmlTemplate,
      excludeChunks: Object.keys(files), // Stops Templates being added to index.html as it is added by CUE
    }),
  ]
});

Shell script

As CUE requires the YAML files before starting it is important that the YML file are created before CUE has started. In production this is fine, however as the webpack-dev-server is always building we need to ensure they created first so you should add something like this too the entry.sh:

if [ "${ENVIRONMENT_NAME}" == "dev" ]
then
  cd /var/www/html/cue-web && npm run webpack:server # see stratup.sh which runs after build step
else
  cd /var/www/html/cue-web && npm run webpack && \
  sed -i "s|CUE_URL|${CUE_URL}|" /etc/escenic/cue-web/config.yml
  # CUE set up
  dpkg-reconfigure cue-web-3.7
  /etc/init.d/content-duplication-service start
  nginx -g "daemon off;"
  rm -rf /var/www/html/cue-web/node_modules # kills node_modules
fi

then in the start.sh

#!/usr/bin/env bash
unlink /var/log/nginx/error.log && unlink /var/log/nginx/access.log
sed -i "s|CUE_URL|${CUE_URL}|" /etc/escenic/cue-web/config.yml
echo 'adding CUE_URL'
dpkg-reconfigure cue-web-3.7
/etc/init.d/content-duplication-service start
# nginx -g "daemon off;"
service nginx start

Creating YAML comments

Then in the webcomponet please add the following comment at the top of your file:

/* ** yml-create bookmark

*/

So yml-create let's the plugin know this is a for creating a yaml config, the name after is the name of the yaml file so this one will create bookmark.yml.

Then the config should be expressed in JSON, the exception is the file name:

FILE: [my - web - component - file];

This will allow webpack to replace with a the correct cache busted file.

Then add you config as a json string like so:

/* ** yml-create bookmark
  {
    "sidePanels":[{
      "id":"book-mark",
      "name":"Bookmark",
      "directive":"cue-custom-panel-loader",
      "isAngular":true,
      "webComponent":{
        "icon":"bookmark-icon",
        "modulePath": FILE:[bookmark]
      },
      "mimeTypes":["*\/*"],
      "homeScreen":true,
      "metadata":[],
      "active":false,
      "order":1250
    }]
  }
*/

Copyright (c) 2019 "Reach Shared Services Ltd"