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

vega-webpack-engine

v3.0.0-rc.15

Published

基于webpack的多入口多出口模块复用构建方案

Downloads

4

Readme

vega-webpack-engine

基于webpack的多入口构建方案

基于tp5.1 开发环境,

配置

配置文件 webpack.config.js

module.exports = {
    output: {
        path: 'public/static-dist/',       // 用于生产环境下的输出目录
        publicPath: '/static-dist/',    // 用于开发环境下的输出目录
    },
    libs: { // 共用的依赖
        'base': ['libs/base.js'], //可以是一个js文件,
        'html5shiv': ['html5shiv'],
        'fix-ie': ['console-polyfill', 'respond-js'], //也可以是一个npm依赖包
        'jquery-insertAtCaret': ['libs/js/jquery-insertAtCaret.js'],
    },
    noParseDeps: [ //不需要解析的依赖,加快编译速度
        'jquery/dist/jquery.js',
        'bootstrap/dist/js/bootstrap.js'
    },
    onlyCopys: [ //纯拷贝文件到输出的libs目录下
    {
      name: 'es-ckeditor',
      ignore: [
        '**/samples/**',
        '**/lang/!(zh-cn.js)',
        '**/kityformula/libs/**',
      ]
    }]
};

package.json

对无关配置进行了省略

{
    "devDependencies": {
        "vega-webpack-engine": "1.0.0"
    },
    "scripts": {
        "dev": "cross-env NODE_ENV=development nodemon --max_old_space_size=4096 node_modules/vega-webpack-engine/dist/webpack.dev.js --parameters webpack.config.js",
        "dev:debug": "npm run dev sourcemap:true",
        "dev:custom": "npm run dev watch:custom",
        "compile": "node --max_old_space_size=4096 node_modules/vega-webpack-engine/dist/webpack.prod.js --parameters webpack.config.js",
        "compile:debug": "npm run compile sourcemap:true",
        "compile:custom": "npm run compile module:custom"
    }
}

nodemon.json

触发重启node服务

{
    "watch": [
        "webpack.config.js",
        ".webpack-watch.log"
    ]
}

注意:需手动在项目根目录下,添加.webpack-watch.log文件

实时编译

实体编译,用于开发模式下,在对前端模块代码修改后,能实时编译生效。

启动实时编译服务:

npm run dev

启动服务后,默认会在本地启动3030端口的前端模块实时编译服务。

可用参数:

  • port:PORT_NUMBER:指定服务端口。例如:
    npm run dev port:3000
  • sourcemap:true:生成 Source map;
  • verbose:true: 显示编译详情,开启此选项后,控制台会输出每个文件被编译的详情;
  • analyzer:true:开启依赖分析工具,打包后文件过大,需要查看都包含了哪些依赖时使用。
  • watch:PATH:指定监听实时编译的资源,以加快实时编译的速度。支持指定Module、插件、主题的前端资源,例如:
    npm run dev watch:custom # 只监听定制开发的前端资源
    npm run dev watch:ExamplePlugin # 只监听 Example 插件的前端资源
    npm run dev watch:example # 只监听 Example 主题的前端资源
    npm run dev watch:custom,ExamplePlugin # 也可同时监听多个的前端资源

编译实体文件

编译实体文体:

npm run compile

可用参数:

  • sourcemap:true:生成 Source map;
  • module:PATH: 指定只编译的前端资源,以加快编译速度。支持指定Module、插件、主题的前端资源,例如:
    npm run compile module:custom # 只编译打包定制开发的前端资源
    npm run compile module:ExamplePlugin # 只编译打包 Example 插件的前端资源
    npm run compile module:example # 只编译打包 Example 主题的前端资源
    npm run compile module:custom,ExamplePlugin # 也可同时编译打包多个前端资源

常见错误

模块不存在

错误提示:

ERROR in multi ....
    Module not found: Error: Cannot resolve 'file' or 'directory' 

解决办法:

rm -rf node_modules
yarn

app crashed

错误提示:

[nodemon] app crashed - waiting for file changes before starting...

解决办法:

在控制台(终端)里输入rs,然后回车。

内存泄漏

错误提示:

<--- Last few GCs --->

      14 ms: Mark-sweep 2.2 (37.1) -> 2.1 (38.1) MB, 2.8 / 0 ms [allocation failure] [GC in old space requested].
      15 ms: Mark-sweep 2.1 (38.1) -> 2.1 (39.1) MB, 1.2 / 0 ms [allocation failure] [GC in old space requested].
      16 ms: Mark-sweep 2.1 (39.1) -> 2.1 (39.1) MB, 0.9 / 0 ms [last resort gc].
      17 ms: Mark-sweep 2.1 (39.1) -> 2.1 (39.1) MB, 1.0 / 0 ms [last resort gc].
...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

解决办法:

重新执行命令:npm run devnpm run compile

端口被占用

events.js:154
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE 0.0.0.0:3030
    at Object.exports._errnoException (util.js:893:11)
    at exports._exceptionWithHostPort (util.js:916:20)
    at Server.__dirname.Server.Server._listen2 (net.js:1246:14)
    ....

解决方法:该错误表明你已经开启了一个端口号为3030的服务,需要先把那个服务关掉。

lsof -i:3030
kill -9 xxxxx(PID编号)

系统默认最大文件打开数过少

报错信息:

watch ...  ENOSPC

解决方法: 在控制台输入

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p