Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuoSmall committed Mar 20, 2018
0 parents commit a84611a
Show file tree
Hide file tree
Showing 34 changed files with 3,426 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": [
"es2015",
"stage-0"
]
}
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/configs/
/dist/
/*.js
/test/unit/coverage/
32 changes: 32 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// https://eslint.org/docs/user-guide/configuring

module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: [
'vue'
],
// add your custom rules here
rules: {
'vue/no-parsing-error': [2, {
"x-invalid-end-tag": false
}],
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
}
}
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Created by .ignore support plugin (hsz.mobi)
*.iml
.project
.settings/

# logs
*.log
.idea
npm-debug.log*

# dependencies
/node_modules

# cache files
.DS_Store
.npm

# middle compile files
/src/sprites/*

# build results
#/pub/
#/entry/

# local configs
lauch.json
.vscode


#nei
/mock/
#/plugins/*
platforms
/dist/
/temp/
assets/tools/

package-lock.json

.temp
9 changes: 9 additions & 0 deletions .postcssrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// https://github.com/michael-ciniawsky/postcss-load-config

module.exports = {
"plugins": {
// to edit target browsers: use "browserslist" field in package.json
"postcss-import": {},
"autoprefixer": {}
}
}
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Commands

### npm start

Starts the development server for you to preview your weex page on browser.
You can also scan the QR code using weex playground to preview weex page on native.

### npm run dev

Open the code compilation task in watch mode.

### npm run ios

(Mac only, requires Xcode)
Starts the development server and loads your app in an iOS simulator.

### npm run android

(Requires Android build tools)
Starts the development server and loads your app on a connected Android device or emulator.

### npm run pack:ios

(Mac only, requires Xcode)
Packaging ios project into ipa package.

### npm run pack:android

(Requires Android build tools)
Packaging android project into apk package.

### npm run pack:web

Packaging html5 project into `web/build` folder.

### npm run test

Starts the test runner.
6 changes: 6 additions & 0 deletions android.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"AppName":"WeexApp",
"AppId":"com.alibaba.weex",
"SplashText":"Hello\nWeex",
"WeexBundle":"index.js"
}
130 changes: 130 additions & 0 deletions configs/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
const path = require('path');
const ROOT = path.resolve(__dirname, '..');
const ip = require('ip').address();
const config = {
root: ROOT,
// webpack-dev-server
pluginConfigPath: 'plugins/plugins.json',
pluginFilePath: 'plugins/plugins.js',
// router
routerFilePath: 'router.js',
// common
templateDir: '.temp',
entryFilePath: 'entry.js',
dev: {
// Various Dev Server settings
contentBase: ROOT,
host: ip,
port: 8081,
historyApiFallback: true,
open: true,
watchContentBase: true,
openPage: 'web/preview.html',
watchOptions: {
ignored: /node_modules/,
aggregateTimeout: 300,
poll: false
},
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'eval-source-map',
env: JSON.stringify('development'),
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: true,
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false,
proxyTable: {},
autoOpenBrowser: false,
errorOverlay: true,
notifyOnErrors: true,
htmlOptions: {
devScripts: `
<script>
window.addEventListener('load', function () {
var is_touch_device = function () {
return 'ontouchstart' in window // works on most browsers
|| 'onmsgesturechange' in window; // works on ie10
};
if(!is_touch_device()) {
if (window.parent === window) { // not in iframe.
window.phantomLimb.stop()
}
}
})
</script>
`
}
},
test: {
env: JSON.stringify('test')
},
prod: {
env: JSON.stringify('production'),
/**
* Source Maps
*/
productionSourceMap: true,
// https://webpack.js.org/configuration/devtool/#production
devtool: '#source-map',
cssSourceMap: true,
productionSourceMap: true
},
nodeConfiguration: {
global: false,
Buffer: false,
__filename: false,
__dirname: false,
setImmediate: false,
clearImmediate: false,
// see: https://github.com/webpack/node-libs-browser
assert: false,
buffer: false,
child_process: false,
cluster: false,
console: false,
constants: false,
crypto: false,
dgram: false,
dns: false,
domain: false,
events: false,
fs: false,
http: false,
https: false,
module: false,
net: false,
os: false,
path: false,
process: false,
punycode: false,
querystring: false,
readline: false,
repl: false,
stream: false,
string_decoder: false,
sys: false,
timers: false,
tls: false,
tty: false,
url: false,
util: false,
vm: false,
zlib: false
}
}
module.exports = config;
20 changes: 20 additions & 0 deletions configs/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Helper functions
const path = require('path');
const ROOT = path.resolve(__dirname, '..');

const root = (args) => {
return path.join(ROOT, 'src', args);
}
const rootNode = (args) => {
return path.join(ROOT, args);
}

const resolve = (dir) => {
return path.join(__dirname, '..', dir)
}

module.exports = {
root,
rootNode,
resolve
}
Binary file added configs/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions configs/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const path = require('path');
const fs = require('fs-extra');
const webpack = require('webpack');
const config = require('./config');
const helper = require('./helper');
const pluginConfigPath = helper.rootNode(config.pluginConfigPath);
const outputPath = helper.rootNode(config.pluginFilePath);

const toLowerCamelCase = key => {
return key.replace(/\b\-\w+\b/g, function(word){
return word.substring(1,2).toUpperCase()+word.substring(2);
});
}

const buildPlugins = () => {
let content = '';
let keys = [];
const plugins =require(pluginConfigPath).web;
if (plugins && plugins.length > 0) {
for(let plugin of plugins){
let camelCaseKey = toLowerCamelCase(plugin.name);
content += `import ${camelCaseKey} from '${plugin.name}';\n`
keys.push(camelCaseKey)
}
content += `export default [${keys.join(',')}];`
fs.outputFileSync(outputPath, content);
return true;
}
else {
if (fs.existsSync(outputPath)) {
fs.unlink(outputPath)
}
return false;
}
}

module.exports = buildPlugins;
Loading

0 comments on commit a84611a

Please sign in to comment.