Skip to content

Commit

Permalink
从 mip-project 迁移至此
Browse files Browse the repository at this point in the history
  • Loading branch information
PengXing committed May 28, 2018
0 parents commit e988b9e
Show file tree
Hide file tree
Showing 369 changed files with 57,725 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"presets": [
[
"env", {
"modules": false
}
],
"vue"
],
"plugins": [
"transform-custom-element-classes",
"syntax-dynamic-import",
"transform-object-rest-spread",
[
"transform-runtime",
{
"helpers": false,
"polyfill": false,
"regenerator": true
}
]
],
"ignore": [
"dist/*.js"
]
}
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
UTF-8
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.{js,styl,html,json}]
indent_size = 4
indent_style = space
[*.md]
trim_trailing_whitespace = false
9 changes: 9 additions & 0 deletions .fecsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
src/page
src/vue
src/vuex
src/router
deps
build
dist
examples
node_modules
31 changes: 31 additions & 0 deletions .fecsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"eslint": {
"env": {
"node": true,
"browser": true
},

"globals": {
"console": true,
"require": true,
"define": true
},

"rules": {
"no-console": 0,
"brace-style": [2, "1tabs"],
"fecs-no-require": "off",
"fecs-prefer-async-await": "off",
"fecs-one-var-per-line": "off",
"prefer-rest-params": "off",
"guard-for-in": "off",
"fecs-export-on-declare": "off",
"fecs-use-for-of": "off",
"fecs-prefer-class": "off",
"fecs-prefer-destructure": "off",
"fecs-prefer-assign-pattern": "off",
"fecs-use-computed-property": "off",
"fecs-valid-map-set": "off"
}
}
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
node_modules
*.log
dist
.vscode
package-lock.json
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018-present mipengine

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
MIP

## 开发

- Node.js v6+
- Clone 代码之后运行

```sh
$ cnpm install # npm install
```

## 常用命令

```sh
# watch and auto re-build dist/mip.js
$ npm run dev
```
监控代码改动并编译代码到 `dist/mip.js`,可通过 `open examples/simple/index.html` 预览效果

```sh
# build all dist files, including npm packages
$ npm run build
```
编译代码到 dist 目录
46 changes: 46 additions & 0 deletions build/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @file webpack build 脚本
* @author [email protected] (wangyisheng)
*/

'use strict';

process.env.NODE_ENV = 'production';

const ora = require('ora');
const rm = require('rimraf');
const path = require('path');
const chalk = require('chalk');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.prod');

const spinner = ora('building for production...');
spinner.start();

rm(path.join(__dirname, '../dist'), err => {
if (err) {
throw err;
}

webpack(webpackConfig, (err, stats) => {
spinner.stop();
if (err) {
throw err;
}

process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
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'));
});
});
20 changes: 20 additions & 0 deletions build/rollup/alias.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @file alias.js
* @author huanghuiquan ([email protected])
*/

const path = require('path');

const resolve = p => path.resolve(__dirname, '../', p);

module.exports = {
vue: resolve('src/vue/platforms/web/entry-runtime'),
compiler: resolve('src/vue/compiler'),
core: resolve('src/vue/core'),
shared: resolve('src/vue/shared'),
web: resolve('src/vue/platforms/web'),
// server: resolve('src/server'),
// entries: resolve('src/entries'),
sfc: resolve('src/vue/sfc'),
deps: resolve('deps')
};
97 changes: 97 additions & 0 deletions build/rollup/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* @file build.js
* @author huanghuiquan ([email protected])
*/

/* eslint-disable */

const fs = require('fs-extra');
const path = require('path');
const zlib = require('zlib');
const rollup = require('rollup');
const uglify = require('uglify-js');

let builds = require('./rollup.config').getAllBuilds();

build(builds);

function build(builds) {
let built = 0;
const total = builds.length;
const next = () => {
buildEntry(builds[built]).then(() => {
built++;
if (built < total) {
next();
}

}).catch(logError);
};

next();
}

function buildEntry(config) {
const output = config.output;
const {file, banner} = output;
const isProd = /min\.js$/.test(file);

return rollup.rollup(config)
.then(bundle => bundle.generate(output))
.then(({code}) => {
if (isProd) {
let minified = (banner ? banner + '\n' : '') + uglify.minify(code, {
output: {
ascii_only: true
},
compress: {
pure_funcs: ['makeMap']
}
}).code;
return write(file, minified, true);
}
else {
return write(file, code);
}
});
}

function write(dest, code, zip) {
return new Promise((resolve, reject) => {
function report(extra) {
console.log(blue(path.relative(process.cwd(), dest)) + ' ' + getSize(code) + (extra || ''));
resolve();
}

fs.writeFile(dest, code, err => {
if (err) {
return reject(err);
}

if (zip) {
zlib.gzip(code, (err, zipped) => {
if (err) {
return reject(err);
}

report(' (gzipped: ' + getSize(zipped) + ')');
});
}
else {
report();
}
});
});
}

function getSize(code) {
return (code.length / 1024).toFixed(2) + 'kb';
}

function logError(e) {
console.log(e);
}

function blue(str) {
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m';
}
Loading

0 comments on commit e988b9e

Please sign in to comment.