This repo tries to show a way to work with grow and webpack on a clean/module based way. Find below Configurations instructions.
Note:
- This project uses Grow, you can find information here
- You need to install Grow in your local machine to have the project working, so, follow the instructions on the link below.
- After you install Grow, follow the instructions to have the project running.
- You also need node/npm, I suggest you install it via nvm. You can find instructions here
- To work better with the css, we are using scss to have extended logic on the css side and webpack to generate the packages.
npm install
npm start
To create a page you need to have under the /content/pages/
a .yaml
file with the page you will create. e.g. index.yaml
In there you will define the view that will contain the template of the page:
---
$path: /
$view: /views/pages/index.html
... more stuff here...
---
Note:
It's very important to keep a module based architecture. The way we can accomplish that is using macros under the grow templating system.
Under the /views/modules/
create a new folder with your module name, in there create a html, js and scss file
-/views/modules/example/example.html
-/views/modules/example/example.js
-/views/modules/example/example.scss
{% macro content(param1, param2, ...etc) %}
<div class="example-module">
{{param1}}
... Whatever you want here
</div>
{% endmacro %}
import './example.scss';
... your JS code
.example-module {
display: none; //This is an example
}
Go to /src/js/[page].js
and add your module:
...
import "../../views/modules/example/example";
st=>start: npm start
e=>end: Bundled
op1=>operation: webpack --watch
op2=>operation: grow run
cond=>condition: Generates dist?
cond2=>condition: Generates pages?
st->op1->cond
op2->cond2
cond(yes)->op2
cond(no)->op1
cond2(yes)->e
cond2(no)->op2