Giter Site home page Giter Site logo

ak-webpack-plugin's Introduction

steamerjs

此包是 steamerjs 开发工具的核心库,其它插件的使用都一概依赖于此库的安装。steamerjs 的其它子命令都可以通过插件去实现,并且信奉:

Plugin is command, use when you plugin in.

插件即命令,即插即可用。

NPM Version Travis Deps Coverage

安装

javascript

// 安装核心库
npm i -g steamerjs

// 安装命令插件
npm i -g steamer-plugin-xxx

设置 NODE_PATH

由于 steamerjs 的命令或脚手架都需要全局安装,尽管steamerjs会尝试兼容,但在某些使用场景下会仍然找到不全局安装的位置,因此推荐设置环境变量 NODE_PATH

常见问题 - NODE_PATH设置

使用

steamer xxx

// 或可使用简写 str
str xxx

内置插件

更新

// 更新本身
npm install -g steamerjs@latest

// 更新插件
npm install -g steamer-plugin-xxx@latest

// 更新脚手架
npm install -g steamer-xxx@latest

交流群

交流QQ群:647150527

ak-webpack-plugin's People

Contributors

lcxfs1991 avatar shixy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ak-webpack-plugin's Issues

A better way to remove the html's crossorigin in offline?

I want to remove the html's crossorigin in offline, because offline doesn't support crossorigin.I do it in this way:

var fs = require('fs');
var path = require('path');
plugins: [
  beforeZip: function() {
    var webserverOfflineDir = path.join(__dirname, 'dist/offline', 'webserver'), 
          webserverFiles = fs.readdirSync(webserverOfflineDir)
    webserverFiles.forEach(function(filename){
      var fullname = path.join(webserverOfflineDir, filename);
      var htmlRegex = './html$';
      if(htmlRegex.test(htmlRegex)) {
        var htmlContent = fs.readFileSync(fullname, 'utf8');
        
        var crossoriginScriptRegex = /<script(\s)+(crossorigin)\s/g;
        htmlContent = htmlContent.replace(crossoriginScriptRegex, '<script ');
        fs.writeFileSync(fullname, htmlContent, 'utf8');
      }
    })
  }
]

I should use fs api to read the webserver's directory,to read the html content, to write the html content.In my opinion, removing the html's crossorigin in offline is necessary,but I should use such a clumsy way to do this.
So is there a better way to change the asset's content in offline?Maybe it can do like this :

plugins: [
  // read each asset in the callback
  beforeZip: function(asset) {
     var postfix = asset.postfix,
           content = asset.content;
    if(postfix === 'html') {
      var crossoriginScriptRegex = /<script(\s)+(crossorigin)\s/g;
      asset.content = content.replace(crossoriginScriptRegex, '<script ');
    }
    // return the asset which has been changed, or hasn't been changed
    return asset;
  }
]

Actually,this is one way to change assets.If this plugin can support any other way to do this,I think it can be more convenient to use.

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.