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

za-webpack-openplatform

v5.0.0-alpha.13

Published

za-webpack-openplatform

Downloads

3

Readme

构建基础支持

  • webpack 4.x
  • babel 7.x
  • vue
  • typescript

babel7 新特性支持

babel7 参考.babelrc

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "modules": false
      }
    ]
  ],
  "plugins": [
    "transform-vue-jsx",
    "@babel/plugin-transform-typescript",
    "@babel/plugin-syntax-dynamic-import",
    ["@babel/plugin-proposal-decorators", { "legacy": true }],
    ["@babel/plugin-proposal-optional-chaining", { "loose": false }],
    ["@babel/plugin-proposal-class-properties", { "loose": true }],
    ["@babel/plugin-transform-runtime", { "corejs": 2 }]
  ],
}

安装项目额外依赖项

devDependencies:

"babel-eslint": "^10.0.2",
"eslint": "^6.1.0",
"eslint-config-za": "^2.0.0",
"eslint-plugin-vue": "^5.2.3",

基础package.json配置

{
  "scripts": {
    "build": "node node_modules/za-webpack-openplatform/build/build.js",
    "build:dll": "node node_modules/za-webpack-openplatform/build/build.dll.js"
  },
  "projectBuildConfig": {}
}

Alias Webpack默认别名目录

  • @:src
  • src:src
  • assets: src/assets
  • config: src/config
  • pages: src/pages
  • components: src/components

多环境编译配置

  • PROJECT_CONFIG: 设置读取的projectBuildConfig配置文件源
{
  "scripts": {
    "build:test": "cross-env PROJECT_CONFIG=project.config.test.js node node_modules/za-webpack-openplatform/build/build.js",
    "build:pre": "cross-env PROJECT_CONFIG=project.config.pre.js node node_modules/za-webpack-openplatform/build/build.js",
    "build:prd": "cross-env PROJECT_CONFIG=project.config.prd.js node node_modules/za-webpack-openplatform/build/build.js"
  }
}

Entry Bundle依赖报告分析

  • BUILD_REPORT: 是否生成Entry文件依赖分析报告,默认false
{
  "scripts": {
    "build:report": "cross-env BUILD_REPORT=true node node_modules/za-webpack-openplatform/build/build.js",
  }
}

postCss启用配置

.posstcssrc.js参考:

plugins: {
    'autoprefixer': {
      browsers: [
        "> 1%",
        "last 2 versions",
        "not ie <= 8",
        "iOS >= 8",
        "Android >= 4"
      ]
    },
    "postcss-pxtorem": {
      rootValue: 14,
      propList: ['*', '!border*'],
    }
  },
};

配置项projectBuildConfig

  • entryPath:配置入口文件:例如src/entry/*.js

  • assetsSubDirectory:静态资源的访问目录前缀:例如promotion,默认/

  • assetsPublicPath:静态资源的访问公共路径:例如/static,默认/

  • commonPath:webpack DLL构建公共入口文件,例如:src/common/*.js

  • assetsCommonPublicPath:webpack DLL构建公共入口文件访问路径,例如:public/promotion,默认取public/ + package.jsonname属性

  • useHtmlWebpackPlugin:webpack SPA HtmlWebpackPlugin配置是否开启,默认false

  • htmlPath:开启useHtmlWebpackPlugin时,自定义设置多个入口HTML Template文件源配置项,例如src/html/*.htmlchunksName需和entryName保持一致,不配置则默认index.html路径读取项目根目录

  • proxyTable:webpack http proxy 跨域代理访问配置

  • useSentryWebpackPlugin: sentry前端监控集成插件,默认false

  • useSourceMap: 是否启用sourcemap,如果配置sentry监控,可以设置为 true

  • version:静态资源的发布版本号,默认取package.jsonversion属性, 默认为1.0.0

  • devPort:开发模式端口号,默认8080

升级常见问题

babel,eslint等插件版本报错:

  • 清除原项目node_modules依赖文件夹后,重新npm install

老项目文件缺失问题:

  • 检查项目目录下是否存在.postcssrc.js, .sentryclirc, .stylelintrc.js, .eslintrc.js, .babelrc文件

Express静态资源路径匹配问题,按如下设置:

  app.use(express.static(path.resolve(__dirname, '../dist/')));
  app.use(express.static(path.resolve(__dirname, '../public/')));

本地热部署报错,注释掉相关代码就可:

  Error: Plugin could not be registered at 'html-webpack-plugin-after-emit'. Hook was not found.
  ...
  // compiler.plugin('compilation', (compilation) => {
  //   compilation.plugin('html-webpack-plugin-after-emit', (cb) => {
  //     hotMiddleware.publish({
  //       action: 'reload',
  //     });
  //     cb();
  //   });
  // });

boom3 sentry/cli install错误:

  npm ERR! errno 1
  npm ERR! @sentry/[email protected] install: `node scripts/install.js`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the @sentry/[email protected] install script.

编译报错:UnhandledPromiseRejectionWarning: TypeError: decl.moveTo is not a function:

  • 检查css样式是否存在同名样式重复代码