ero-cli
v1.0.5-1
Published
CLI工具
Downloads
23
Readme
support
- 支持 HRM
- 支持 code spliting
- 支持生成 hash 的配置
- 支持代码运行错误的界面提示
使用方式
CLI 命令执行方式
ero init : 按照相应的提示步骤进行模板项目的创建 【文档系统定制化的命令,生成ant-design模板,其他项目无需执行此项】
ero --help : 查看 CLI 命令帮助信息
ero run server : 启动服务
ero run build : 代码打包
.webpackrc.js 配置示例
- 备注说明:基本配置跟 webpack4.0 官网配置一样
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const cwd = process.cwd();
module.exports = {
entry: { // 入口文件
app: [
path.resolve(cwd, 'entry.js')
],
vendor: [
'react',
'react-dom',
'react-router',
],
pollyfill: [
path.resolve(cwd, 'pollyfill.js')
],
},
output: { // 输出文件
publicPath: '/',
filename: 'js/[name].js',
},
externals: { // 第三方库引用
},
plugins: [
],
port: 9898, // 自定义服务端口 默认端口: 9898
hash: true, // css 是否需要 hash
extractCss: true, // 是否单独剥离 css default: true
imgPublicPath: '/' // 线上图片地址引用路径,目前只能对背景引用地址进行处理
target: 'default', // 生成代码的模式 可选项:commonjs -- 针对npm发包代码
resolve: {}, // 简化代码 import 路径
externalsConfig: {}, // 可自行进行webpack配置,相同的webpack参数配置会覆盖已提供的配置参数
ts: false, // 是否需要支持ts功能
eslint: false, // 是否需要支持eslint
}
ISSUE
- 如果出现 node-sass 版本问题
解决方法: 使用 npm rebuild node-sass
DockerFile 示例
- 如果项目使用docker进行项目打包,可以参考如下配置
FROM node:10.4.0-stretch as builder
EXPOSE 80
RUN npm config set registry http://registry.npm.taobao.org \
&& npm install -g ero-cli
WORKDIR /code
ADD package.json /code
RUN npm install
ADD . /code
RUN npm run inner:build \
&& npm run home:build
FROM nginx:alpine
COPY --from=builder /code/tuijian /usr/share/nginx/html/tuijian
COPY --from=builder /code/static /usr/share/nginx/html/tuijian/static