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

aem-optimized

v2.1.8

Published

Spins up a dedicated server that pulls host page and replaces clientlibs with locals

Downloads

942

Readme

aem-optimized

Version 2! All new, all shiny, all vite! Allows for HMR and other features, tested directly against your production publisher with real content. This package is intended to develop directly against authored content instead of dummy content. All features like HMR are first class citizins thanks to the power of vite. This package requires vite as a peer-dependency. At the moment glob imports in sass are not supported. So make sure that @import './**/*.scss' is replaced with proper imports referencing the files directly.

AEM-Optimized utilizes the vite.config.js, so all configurations can be made in one file!

How to use

  1. install package: npm i -D aem-optimized
  2. create a new config-file named vite.config.js and define a aemOptimized object with the following attributes: host, clientlibs,port, headers, entry. The host-entry can be any target, so even your production environment's publisher. If working against a local author you can also pass a wcmmode: 'disabled' for better visuals.
  3. run script: npx aem-optimized
  4. open a page in 'view as published' and change the aem-port to the aem-optimized-port. e.g. localhost:4502/content/mysite/us/en.html to localhost:3000/content/mysite/us/en.html
  5. Change some css values, save and watch the changes happen without a page refresh

Sample Configs

// vite.config.js
import { defineConfig } from "vite";
import autoprefixer from "autoprefixer";
const path = require("path");

const headers = {
    authorization: 'Basic YWRtaW46YWRtaW4=',
};
const port = 3000;
const entry = "/src/main/webpack/site/main.js";
const target = "http://localhost:4502";
const clientlibs = ["clientlib-site"];
const proxies = generateProxies(clientlibs, entry);
export default defineConfig({
    aemOptimized: {
        host: target,
        headers: {
            ...headers,
        },
        clientlibs,
        entry,
        port,
        wcmmode: 'disabled'
    },
    server: {
        proxy: {
            ...proxies,
        },
    },
    css: {
        postcss: {
            plugins: [autoprefixer],
        },
    },
});

function generateProxies(clibs, entryPoint) {
    const libs = clibs.map((lib) => [
        `^((?!${lib}.*.(js|css)|html|${entryPoint.split("/").pop()}|@|/${
            entry.split("/")[1]
        }/|node_modules).)*$`,
        {
            target,
            changeOrigin: true,
            secure: true,
            headers: {
                ...headers,
            },
        },
    ]);

    return Object.fromEntries(libs);
}