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

@toolspack/ttd-deploy-webpack-plugin

v2.0.9

Published

webpack plugin from ttd deploy

Downloads

5

Readme

TTD Deploy Webpack Plugin

命命行参数:

| 短参数 | 长参数 | 说明 | 默认 | |--|--|--| -- | | -V | --version | output the version number | | -E | --envs | 增加编译环境('{"dev": 环境配置, "prod": {"target": "http:...","needRemarks":true,"needFbkey":true,"package": "name"}}}') | (default: {}) | | -e | --env | 编译环境(可以使用 dev?level=1&debug=true 来传参) | | -n | --envname | 项目中的环境变量名(会在项目是生成 __TTD_ENV__ 环境变量) | (default: "__TTD_ENV__") | | | --no-deploy | 不部署(默认在生产环境且指定target,package时自动部署) | | -d | --dist | 打包目录 | | -p | --package | 默认包名 | | -o | --output | 输出目录 | (default: "output") | | -c | --cookie | cookie | fb_user=%E5%91%A8%E5%BF%97%E5%BC%BA | | -z | --zipPath | zip文件的目录结构 | (default: "dist") | | -m | --remarks | 发布备注 | (default: "") | | -k | --fbkey | 发布key | (default: "") | | -h | --help | 查看帮助说明 |

环境配置:

| key | 必传 | 类型 | 说明 | 默认 | |--|--|--| -- | -- | | target | 否 | string | 上传地址 | undefined | | needRemarks | 否 | boolean | 是否需要发包备注 | false | | needFbkey | 否 | boolean | 是否需要发包key | false | | package | 否 | string | 发包包名 | '' |

使用

安装

npm 安装 npm install @toolspack/ttd-deploy-webpack-plugin

webpack配置

然后在webpack.config.js 中:

const TTDDeployWebpackPlugin = require('@toolspack/ttd-deploy-webpack-plugin')

module.exports = {
  entry: {
    app: "./src/main.js"
  },
  plugins: [
    new TTDDeployWebpackPlugin([
      '-E', JSON.stringify({
      dev: {},
      prod:{target: 'http://192.168.88.122:9990/upfile.php?pk_id=99999'},
    }),
    '-d', 'dist',
     '-p', 'package_name',
     '-z', 'package/dist'
     ], {
       allowUnknownOption: true,
     }),
  ]
}

项目中

在 /src/env.js 中:

// __TTD_ENV__ 是 TTDDeployWebpackPlugin 插件生成的 环境变量
const env = __TTD_ENV__ // dev, prod

const configs = {
  dev: { // 开发环境
    baseUrl: 'http://192.168.0.252:8011',
  },
  prod: { // 线上
    baseUrl: 'http://pe.totodi.com:13811',
  },
}

const config = configs[env]

export default config

npm命令

在 package.json 中:

{
  "scripts": {
    "start": "webpack -e dev",
    "build": "node build/build.js -e prod",
  },
}

命令行中

在 cmd 执行 npm run start -- -e prod?level=1 可以用 ? 来传更多参数

已知问题

如果需要动态注入全局环境变量, v2中使用 webpack v4.13.0 之后的 DefinePlugin.runtimeValue,但有些项目使用的webpack版本较低, 所以在v1版本使用的DefinePlugin, 但可能会有未知的问题.