vhtml / webpack-MultiplePage

基于webpack的前端工程化方案(自动入口配置及后端模板)
302 stars 56 forks source link

如果是可继承类的模板呢? #11

Open 1166544 opened 7 years ago

1166544 commented 7 years ago

这种inject body和script标记的动态inject方式就不适用了吧? 因为nunjucks可以继承,一般头和公共部份都通过extends方式实现。即每个模板页有可能这个样子:

{% extends "../../layout/layout.tpl" %}

{% block content %}

{% include "../widget/item/item.tpl" %} {% if comments.length > 0%}
    [-] {{ comment.by }} {{ comment.time | relativeTime }}
    {{ helper.shtml(comment.text) }}
    {% endfor %}
{% else %}

No comments yet.

{% endif %}

{% endblock %}

请问如果是这种没有script和body标签的。该如何处理inject问题呢?

vhtml commented 7 years ago

根据我个人的理解,是不太容易做到的,除非有这样的插件可以处理。文中使用的html-webpack-plugin本身就是只针对类html结构的一个插件。

htmlcss23 commented 7 years ago

$ npm run build

webpack-f2e@0.1.0 build D:\work\webpack\webpack-MultiplePage-master rm -rf public/ views/ && NODE_ENV=production webpack --progress --hide-modules

'NODE_ENV' ²»ÊÇÄÚ²¿»òÍⲿÃüÁҲ²»ÊÇ¿ÉÔËÐеijÌÐò »òÅú´¦ÀíÎļþ¡£

npm ERR! Windows_NT 6.3.9600 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "build" npm ERR! node v6.10.0 npm ERR! npm v3.10.10 npm ERR! code ELIFECYCLE npm ERR! webpack-f2e@0.1.0 build: rm -rf public/* views/* && NODE_ENV=production webpack --progress --hide-modules npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the webpack-f2e@0.1.0 build script 'rm -rf public/ views/ && NODE_ENV=production webpack --progress --hide-modules'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the webpack-f2e package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! rm -rf public/ views/ && NODE_ENV=production webpack --progress --hide-modules npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs webpack-f2e npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls webpack-f2e npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! D:\work\webpack\webpack-MultiplePage-master\npm-debug.log

这个报错遇到过么