1.5 项目发布
github pages & npm package
Github Pages发布
root 路径
docs 路径
gh-pages 分支
npm 发布组件包
webpack配置
npm 配置
npm 发布
References
最后更新于
github pages & npm package
最后更新于
module.exports = {
...
output: {
path: path.resolve(process.cwd(), 'docs'),
...
},
...
}...
"scripts": {
...
"build:docs": "cross-env NODE_ENV=development webpack --config build/webpack.docs.js",
...
},
...├─docs
├─learning-element2
├─LICENSE
├─README.md // 安装插件
npm install -D gh-pages
// package.json 添加部署命令
"scripts": {
"deploy": "gh-pages -d dist"
}npm i -D progress-bar-webpack-pluginconst path = require('path');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const config = require('./config');
module.exports = {
mode: 'production',
entry: {
app: ['./src/index.js'], // Entry descriptor 传入一个对象 ./src/index.js
},
output: {
path: path.resolve(process.cwd(), './lib'), // 绝对路径
publicPath: '/dist/', // 相对于服务(server-relative)
filename: 'me-vue-ui.common.js',
chunkFilename: '[id].js',
library: {
type: 'commonjs2', //配置将库暴露的方式
export: 'default', // 指定哪一个导出应该被暴露为一个库
},
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: config.alias,
modules: ['node_modules'],
},
// externals: config.externals, //外部扩展
performance: {
// 控制 webpack 如何通知「资源(asset)和入口起点超过指定文件限制」
hints: false, // 不展示警告或错误提示
},
// 可以在统计输出里指定你想看到的信息
stats: {
children: false, // 是否添加关于子模块的信息
},
optimization: {
//告知 webpack 使用 TerserPlugin 或其它在 optimization.minimizer 定义的插件压缩 bundle
minimize: false,
},
module: {
rules: [
{
test: /\.(jsx?|babel|es6)$/,
include: process.cwd(),
exclude: config.jsexclude,
loader: 'babel-loader',
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
compilerOptions: {
preserveWhitespace: false,
},
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: path.posix.join('static', '[name].[hash:7].[ext]'),
},
},
],
},
plugins: [new ProgressBarPlugin(), new VueLoaderPlugin()],
};
...
"scripts": {
...
"dist": "webpack --config build/webpack.common.js ",
...
},
...// examples\main.js
// import MeUI from '../src/index';
import MeUI from '../lib/me-vue-ui.common';{
"name": "me-vue-ui",
"version": "0.1.2",
"description": "A Vue.js 2.X UI Toolkit for Web",
"main": "lib/me-vue-ui.common.js",
"keyword": [
"me-vue",
"vuejs",
"components",
"ui-kit"
],
"repository": {
"type": "git",
"url": "git+https://github.com/andurils/code-examples.git"
},
"author": "anduril",
"license": "MIT",
"homepage": "https://andurils.github.io/code-examples"
}
# 忽略目录
build/
dist/
examples/
packages/
public/
src/
test/
docs/
# 忽略指定文件
.eslintignore
.prettierignore
.eslintrc.js
.prettierrc.js
babel.config.json npm config set registry http://registry.npmjs.org