-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
274 additions
and
1,735 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
title: webpack-template | ||
date: | ||
author: Mizok | ||
version: 0.1.0 | ||
tags: | ||
--- | ||
|
||
## Introduction | ||
|
||
A webpack boilerplate that uses `ejs` as the template engine. | ||
|
||
## Installation And Uasge | ||
|
||
- Run `npm install` or `npm i` first to install all dependencies. | ||
- Run `npm run dev` to start the dev-server. | ||
|
||
### Where to put my entry `ejs` files? | ||
|
||
You have to put your entry `ejs` files in `./src/pages`. | ||
|
||
### I would like to make some `ejs` files sharable as templates(ex:header.ejs),how can I make this? | ||
|
||
- You have to put your template `ejs` files in `./src/template`. | ||
- In your `ejs` file which you want to insert your template: | ||
|
||
```html | ||
<%- include('./src/template/header.ejs') %> | ||
``` | ||
|
||
for more detail, please check links below: | ||
|
||
- https://github.com/dc7290/template-ejs-loader | ||
- https://ejs.bootcss.com/ | ||
|
||
### How to connect `ejs` file with entry `ts` file/ entry `scss` file? | ||
|
||
Here we are actually talking about `webpack` entry chunks. | ||
|
||
When designing this boilerplate, we tried to make chunk setting easy. | ||
|
||
By Default, if you want your output page name to be `index.html`, and you are not going to use a specfic entry chunk, you will need: | ||
|
||
- an `index.ejs` file in `./src/pages` | ||
- an `index.ts` file in `./src/ts` | ||
- an `index.scss` file in `./src/scss` | ||
|
||
On the other hand, if you want your output page name to be `index.html`,and using a chunk named `main`, then you will need: | ||
|
||
- an `index.main.ejs` file in `./src/pages` | ||
- an `main.ts` file in `./src/ts` | ||
- an `main.scss` file in `./src/scss` | ||
|
||
### I want to get webpack `mode` environment argument in `ejs` file, how can I make this? | ||
|
||
Like this (in your `ejs` file) : | ||
|
||
```ejs | ||
<div><%= mode%></div> | ||
``` | ||
|
||
### My `img` tag is not showing because `webpack` seems to get my `src` wrong. | ||
|
||
Check if you are using `alias` path , but not relative path, like below: | ||
|
||
```html | ||
<img src="~@img/logo.png"> | ||
``` | ||
|
||
|
||
|
||
|
Oops, something went wrong.