npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@51npm/freedom-middleware-webpack4

v1.1.0

Published

webpack4前端项目开发构建中间件

Downloads

35

Readme

freedom-middleware-webpack4构建中间件

中间件统一管理了项目开发中大概95%以上的构建配置。在对项目构建时,中间件会自动合并项目中的webpack.config.js(构建项目必须存在的webpack扩展约束文件)文件,然后进行项目的构建。

npm NPM Version npm

Freedom-middleware-webpack4构建中间件支持构建的项目

  • 使用less、sass、ts、vue、react、ejs,jade以及es6开发的项目
  • 中间件生成的webpack.config.js:允许开发者根据项目需要自行扩展构建配置或者覆盖中间件本身的配置
  • 中间件生成的.babelrc文件:允许开发者自行定义babel相关构建配置
  • 中间件生成的tsconfig.json:允许开发者自行定义ts编译选项
  • postcss.config.js:允许开发者自行定义样式处理方式

freedom-middleware-webpack4安装

npm install @51npm/freedom-middleware-webpack4

freedom-middleware-webpack4构建中间件使用

var webpackBuild = require("@51npm/freedom-middleware-webpack4");
(async function () {
  var params = {
    port: 9090,
    env: "dev",//环境变量,dev:开发环境;prod:生成环境
    srcDir:"src",
    entryDir:"./src/scripts/entry",//编译入口目录,会跟src组装一起/src/entry
    publicPath: `//{域名}/oneTomany/0.0.1`,
    build: `./build`,//生产环境prod构建的资源存放的目录,在dev环境中该值忽略
    proxy: {
      context: ["/api", "/auth","/award"],
      options: {
        target: 'http://localhost:8080'
      }
    }
  };
  await webpackBuild(params);
})();

Freedom-middleware-webpack4构建中间件的参数说明

{
  "root":"",//根目录,不写默认为process.cwd()
  "port":"本地环境dev启动的端口后",
  "env":"环境变量,dev:开发环境;prod:生成环境",
  "srcDir": "src",// 源码目录,默认源码目录为:process.cwd()
  "entryDir":"./src/scripts/entry",//webpack编译入口目录,为srcDir源码目录中的相对目录,跟srcDir一起构成完成的编译目录
  "publicPath":"构建资源的替换路径,比如:css中的图片路径",
  "build":"生产环境prod构建的资源存放的目录,在dev环境中该值忽略",
  "proxy":{ //反向代理设置
    "context":["/api", "/auth","/award"],//要拦截的url
    "options":{ //设置代理端口
      "target": 'http://localhost:8080'	
    }
  }
}

dev环境下,文件编译的目录存储于根目录下的__build目录

备注

构建项目下必须要有webpack.config.js文件,配置(webpack的配置格式)如下:

module.exports = function () {
  var extendConf = {
    plugins: [
      
    ],
    resolve: {
     
    },
    module: {
      rules: [
        
      ]
    }
  };
  return extendConf;
};

版本更新说明

| 发布时间 | 发布版本 | 发布功能 | | ---------- | -------- | -------------- | | 2020-06-16 | 1.0.8 | 修改readme说明 |