markdalgleish / static-site-generator-webpack-plugin

Minimal, unopinionated static site generator powered by webpack
MIT License
1.61k stars 97 forks source link

Documentation improvement and examples request #135

Open incompletude opened 6 years ago

incompletude commented 6 years ago

Hey guys, thank you for all the nice work.

I'm trying to use static-site-generator-webpack-plugin to build a pagination based on locals data. I think the way to go is use ejs templates and locals properties, but I'm not really sure how to put it together.

It would be nice to have an examples folder (not only React ones, please! JAMStack it is!) and an improved documentation for assets and templates.

Thank you.


I'm not using React. I have added the following code to my index.js and a template.ejs file inside the src folder, but I'm not sure how to put it together because I'm getting You may need an appropriate loader to handle this file type.

Should I have ejs-loader?

var template = require("./template.ejs");

export default data => {
    const assets = Object.keys(data.webpackStats.compilation.assets);
    const css = assets.filter(value => value.match(/\.css$/));
    const js = assets.filter(value => value.match(/\.js$/));
    return template({ css, js, ...data });
};