Commit 6a2c8003 by zsh

初始化项目

parents
{
// 业务代码使用
// 全局方式引入, 会污染全局环境
// 执行顺序: 从下往上, 从右往左
"presets": [
["@babel/preset-env", {
"targets": {
"chrome": "10"
},
"corejs": "2",
"useBuiltIns": "usage" // 根据已使用的语法添加polyfill, 无需单独再引入(import '@babel/polyfill')
}]
],
"plugins": ["@babel/plugin-syntax-dynamic-import"]
// 类库等代码使用, 且无需引入polyfill
// 闭包方式引入, 不会污染全局环境
// "plugins": [["@babel/plugin-transform-runtime", {
// "corejs": 2,
// "helpers": true,
// "regenerator": true,
// "useESModules": false
// }]]
}
root = true
[*]
charset = uft-8
end_of_line = lf
indent_size = 4 # 代码缩进数量
indent_style = space # 代码缩进类型 - 空格
insert_final_newline = true # 保存文件时自动在文件末尾添加一行空行(需安装对应的插件 - EditorConfig for VSCode)
trim_trailing_whitespace = true # 自动删除行末尾的空格
{
"extends": "standard",
"plugins": [
"html"
],
"parser": "babel-eslint",
"rules": {
"indent": ["error", 4], // 缩进4行
"no-new": "off" // 允许使用 new 关键字
}
}
## 徐汇教育局项目
```
npm install
开发环境
npm run dev
打包部署
npm run build
```
### 页面名称
```
```
// 此文件是项目打包服务,用来构建一个全量压缩包
// 命令: npm run build
"use strict";
// node for loading
const ora = require("ora");
// rm-rf for node
const rm = require("rimraf");
// console for node
const chalk = require("chalk");
// path for node
const path = require("path");
// webpack
const webpack = require("webpack");
// webpack production setting
const config = require("./webpack.prod.conf");
// 指定删除的文件
const rmFile = path.resolve(__dirname, "../dist");
// build start loading
const spinner = ora("building for production...");
spinner.start();
// 构建全量压缩包
rm(rmFile, function(err) {
if (err) throw err;
webpack(config, function(err, stats) {
spinner.stop();
if (err) throw err;
process.stdout.write(
stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + "\n\n"
);
if (stats.hasErrors()) {
console.log(chalk.red(" Build failed with errors.\n"));
process.exit(1);
}
console.log(chalk.cyan(" Build complete.\n"));
console.log(
chalk.yellow(
" Tip: built files are meant to be served over an HTTP server.\n" +
" Opening index.html over file:// won't work.\n"
)
);
});
});
// Vue-loader配置
const { dev = {}, build = {} } = require('../config/config')