2.1.8 • Published 1 year ago

aem-optimized v2.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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);
}
2.1.2

2 years ago

2.0.3

2 years ago

2.1.1

2 years ago

2.0.2

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.0.4

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.1.8

1 year ago

2.1.7

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago