Page Skeleton Webpack Plugin 使用教程

Page Skeleton Webpack Plugin 使用教程

page-skeleton-webpack-pluginWebpack plugin to generate the skeleton page automatically项目地址:https://gitcode.com/gh_mirrors/pa/page-skeleton-webpack-plugin

1. 项目的目录结构及介绍

page-skeleton-webpack-plugin/
├── examples/
│   ├── sale/
│   └── ...
├── lib/
├── src/
├── .gitignore
├── .npmignore
├── .travis.yml
├── LICENSE
├── README.md
├── package.json
└── webpack.config.js
  • examples/: 包含示例项目的目录,其中 sale/ 是一个具体的示例。
  • lib/: 编译后的文件目录。
  • src/: 源代码目录。
  • .gitignore: Git 忽略文件配置。
  • .npmignore: NPM 忽略文件配置。
  • .travis.yml: Travis CI 配置文件。
  • LICENSE: 项目许可证。
  • README.md: 项目说明文档。
  • package.json: 项目依赖和脚本配置。
  • webpack.config.js: Webpack 配置文件。

2. 项目的启动文件介绍

项目的启动文件主要是 webpack.config.js,它包含了 Webpack 的基本配置和插件的配置。以下是一个简化的示例:

const HtmlWebpackPlugin = require('html-webpack-plugin');
const { SkeletonPlugin } = require('page-skeleton-webpack-plugin');
const path = require('path');

const webpackConfig = {
  entry: 'index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'index_bundle.js'
  },
  plugins: [
    new HtmlWebpackPlugin({
      // Your HtmlWebpackPlugin config
    }),
    new SkeletonPlugin({
      pathname: path.resolve(__dirname, `$[customPath]`), // the path to store shell file
      staticDir: path.resolve(__dirname, 'dist') // the directory for static files
    })
  ]
};

module.exports = webpackConfig;

3. 项目的配置文件介绍

项目的配置文件主要是 package.jsonwebpack.config.js

package.json

{
  "name": "page-skeleton-webpack-plugin",
  "version": "1.0.0",
  "description": "Webpack plugin to generate the skeleton page automatically",
  "main": "lib/index.js",
  "scripts": {
    "dev": "webpack --mode development",
    "build": "webpack --mode production"
  },
  "dependencies": {
    "html-webpack-plugin": "^4.5.0",
    "page-skeleton-webpack-plugin": "^1.0.0"
  },
  "devDependencies": {
    "webpack": "^4.44.2",
    "webpack-cli": "^3.3.12"
  }
}
  • name: 项目名称。
  • version: 项目版本。
  • description: 项目描述。
  • main: 入口文件。
  • scripts: 脚本命令,如 devbuild
  • dependencies: 生产环境依赖。
  • devDependencies: 开发环境依赖。

webpack.config.js

const HtmlWebpackPlugin = require('html-webpack-plugin');
const { SkeletonPlugin } = require('page-skeleton-webpack-plugin');
const path = require('path');

const webpackConfig = {
  entry: 'index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'index_bundle.js'
  },
  plugins: [
    new HtmlWebpackPlugin({
      // Your HtmlWebpackPlugin config
    }),
    new SkeletonPlugin({
      pathname: path.resolve(__dirname, `$[customPath]`), // the path to store shell file
      staticDir: path.resolve(__dirname, 'dist') // the directory for static files
    })
  ]
};

module.exports = webpackConfig;
  • entry: 入口文件。
  • output: 输出配置。
  • plugins: 插件配置,包括 HtmlWebpackPluginSkeletonPlugin

以上是 page-skeleton-webpack-plugin 项目的目录结构、启动文件和配置文件的介绍。希望这份

page-skeleton-webpack-pluginWebpack plugin to generate the skeleton page automatically项目地址:https://gitcode.com/gh_mirrors/pa/page-skeleton-webpack-plugin

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林菁琚

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值