Giter Site home page Giter Site logo

Comments (13)

lcxfs1991 avatar lcxfs1991 commented on May 26, 2024

没试过,你加个jade的loader试试?

from html-res-webpack-plugin.

xiaolongyuan avatar xiaolongyuan commented on May 26, 2024

晕 作者你回复真快

from html-res-webpack-plugin.

xiaolongyuan avatar xiaolongyuan commented on May 26, 2024
doctype html
html(lang='zh_CN')
  head
    meta(charset='utf-8')
    meta(name='viewport', content='width=device-width, height=device-height, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0')
    block css
      if mode != 'dev'
        style.
          !{css}
    block title
      title #{title}
  body
    #app
    script(type='text/javascript').
      window.Rexxar = window.Rexxar || {};
      window.Rexxar.Lifecycle = window.Rexxar.Lifecycle || {};
      window.Rexxar.Lifecycle.onPageVisible = function() {};
      window.Rexxar.Lifecycle.onPageInvisible = function () {};

    script(type='text/javascript').
      function showErrorMsg(msg, otherNode) {
        if (document.getElementById('errorShowing')) return;
        var errorNode = document.createElement('div');
        errorNode.id = 'errorShowing';
        errorNode.style.color = '#494949';
        errorNode.style.textAlign = 'center';
        errorNode.style.fontSize = '18px';
        errorNode.style.margin = '200px 0 0';
        var errorMsg = document.createElement('p');
        errorMsg.appendChild(document.createTextNode(msg));
        errorNode.appendChild(errorMsg);
        if (otherNode && otherNode.nodeName) {
          errorNode.appendChild(otherNode);
        }
        document.body.appendChild(errorNode);
      }

    script(type='text/javascript').
      function logSend(code) {
        var ua = navigator.userAgent.toLowerCase();
        var rexxarInfo = ua.match(/rexxar( |\/)([0-9.]*)/);
        var rexxarVersion = rexxarInfo ? rexxarInfo.pop().split('.').slice(0, 3).join('.') : '';
        var label = {msg: code};
        var httpRequest = new XMLHttpRequest();
        httpRequest.onreadystatechange = function () {
          if (httpRequest.readyState === XMLHttpRequest.DONE) {
            if (httpRequest.status === 200) {
            }
          }
        }
        if (/android/i.test(ua) && rexxarVersion >= '1.2.100') {
          var url = 'http://rexxar-container/api/log?_rexxar_method=POST&event=rexxar_page_error&label='
            + encodeURIComponent(JSON.stringify(label));
          httpRequest.open('GET', url, true);
          httpRequest.send();
        } else {
          httpRequest.open('POST', 'http://rexxar-container/api/log', true);
          httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          httpRequest.send('event=rexxar_page_error&label=' + encodeURIComponent(JSON.stringify(label)));
        }
      }

    script(type='text/javascript').
      window.onerror = function (errorMsg) {
        var appNode = document.getElementById('app');
        if (appNode.childNodes.length <= 0) {
          var errorCode = document.createElement('div');
          errorCode.style.fontSize = '14px';
          errorCode.style.color = '#9b9b9b';
          errorCode.style.margin = '12px';
          errorCode.appendChild(document.createTextNode('展开详情'));
          errorCode.addEventListener('click', function () {
            this.innerText = errorMsg;
          });
          showErrorMsg('糟糕,页面出现了错误 :(', errorCode);
        }
        logSend(errorMsg);
      }

    block commonjs
      if mode != 'dev'
        script(src='#{vendorSrc}')

    if mode == 'dev'
      script(type='text/javascript').
        window.VENDOR_START = true;
        window.VENDOR_END = true;

    script(type='text/javascript').
      if (!window.VENDOR_START) {
        logSend('Vendor assets failed to load.');
        var reloadBtn = document.createElement('div');
        reloadBtn.style.fontSize = '14px';
        reloadBtn.style.color = '#494949';
        reloadBtn.style.margin = '12px';
        reloadBtn.appendChild(document.createTextNode('点击重试'));
        reloadBtn.addEventListener('click', function () {
          window.location.reload();
        });
        showErrorMsg("资源加载失败啦 :(", reloadBtn);
      } else if (window.VENDOR_START && !window.VENDOR_END) {
        logSend('Vendor assets load incomplete.');
        var reloadBtn = document.createElement('div');
        reloadBtn.style.fontSize = '14px';
        reloadBtn.style.color = '#494949';
        reloadBtn.style.margin = '12px';
        reloadBtn.appendChild(document.createTextNode('点击重试'));
        reloadBtn.addEventListener('click', function () {
          window.location.reload();
        });
        showErrorMsg("资源加载失败啦 :(", reloadBtn);
      }

    block js
      if mode == 'dev'
        script(src='#{scriptSrc}')
      else
        script.
          !{js}

from html-res-webpack-plugin.

xiaolongyuan avatar xiaolongyuan commented on May 26, 2024

我想控制 js出现的位置

from html-res-webpack-plugin.

lcxfs1991 avatar lcxfs1991 commented on May 26, 2024

我这个是做匹配的,看起来暂时做不到,有什么好建议不?

from html-res-webpack-plugin.

xiaolongyuan avatar xiaolongyuan commented on May 26, 2024

如果兼容 jade 的话 我想再结合:

对于全局共享的 verdor 直接:

<script src="verdor"></script>

对于多页面每个页面不同的chunk css、js 资源 提供一个通用占位符 和接口 动态写

对于我这个需求 我感觉我只需在 chunks 中只配置 此页面的 例如 就只用写 chunks = ['cashbox/index']

from html-res-webpack-plugin.

xiaolongyuan avatar xiaolongyuan commented on May 26, 2024

奇怪 就算用的 html 模板 发现没有对内容进行替换

from html-res-webpack-plugin.

xiaolongyuan avatar xiaolongyuan commented on May 26, 2024
<script src="vendor"></script> 原样输出

from html-res-webpack-plugin.

lcxfs1991 avatar lcxfs1991 commented on May 26, 2024

from html-res-webpack-plugin.

xiaolongyuan avatar xiaolongyuan commented on May 26, 2024

配置了 chunks = ['manifest','vendor', pathname]

from html-res-webpack-plugin.

lcxfs1991 avatar lcxfs1991 commented on May 26, 2024

你是用jade输出么?

from html-res-webpack-plugin.

xiaolongyuan avatar xiaolongyuan commented on May 26, 2024

不是 html

from html-res-webpack-plugin.

xiaolongyuan avatar xiaolongyuan commented on May 26, 2024

compilation.plugin('html-webpack-plugin-before-html-processing', function(htmlPluginData, callback) {
htmlPluginData.html += 'The magic footer';
callback();
});

在HtmlWebpackPlugin插件中 这个 compilation 哪来的啊?

from html-res-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.