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

wwy-map

v1.0.2

Published

地图sdk,支持高德地图,百度地图,腾讯地图,包含网站演示

Downloads

2

Readme

项目初始化和 webpack 配置

原文地址: https://juejin.cn/post/6950905030635421710

创建项目

新建一个空的文件夹,使用npm init 来初始化项目,并安装 vue 模块。

carbon (17).png

修改目录结构

根目录中添加文件夹

carbon (18).png

根目录下创建项目配置文件: .gitignore README.md
public 目录下,创建模板页文件: favicon.ico index.html examples 目录下,创建示例入口文件: App.vue main.js logo.png


项目使用 webpack 实现模块化管理和打包。

局部安装 webpack

carbon (16).png

webpack-cli最新为4.X版本,webpack-dev-server无法正常运行,安装时需要指定版本(确保两模块版本皆为3.X)。

carbon (14).png

webpack-cli 提供了许多命令来使 webpack 的工作变得简单。官方文档
webpack-dev-server为你提供了一个简单的 web server,并且具有 live reloading(实时重新加载) 功能。官方文档

安装 webpack loaders

webpack 使用 loader 对文件进行预处理。可以构建包括 JavaScript 在内的任何静态资源。
官方插件列表 webpack 插件中文文档

carbon (15).png

参考
vue-loader 详解: https://segmentfault.com/a/1190000020629508
html-webpack-plugin 详解:https://www.cnblogs.com/wonyun/p/6030090.html

webpack 配置

build目录下创建 webpack 配置文件webpack.config.js,提供入口(entry)模式(Mode)输出(output)模块(Module)插件(Plugins)开发服务器(DevServer)等配置选项。官方文档

carbon (11).png

0x02.项目运行

npm scripts 配置

在 npm 脚本中新增 webpack 命令,执行的命令会自动去node_modules寻找,不用加上目录。

修改package.json配置

.
...
"scripts": {
    "build:dist": "webpack --config  build/webpack.config.js",
    "dev": "webpack-dev-server --config build/webpack.config.js"
},
...
.

cross-env 配置

cross-env 是一款运行跨平台设置和使用环境变量的脚本,不同平台使用唯一指令,无需担心跨平台问题。

carbon (13).png

修改package.json配置

.
...
"scripts": {
    "build:dist": "cross-env NODE_ENV=development webpack --config  build/webpack.config.js",
    "dev": "cross-env NODE_ENV=development webpack-dev-server --config build/webpack.config.js"
},
...
.

运行测试

命令行窗口中,在该项目根目录下输入npm run dev 即可进行本地开发调试。

成功运行后,项目第一个页面结果如下:

最终目录结构