Initial Commit ES6 barebone
This commit is contained in:
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
dist
|
||||||
31
.eslintrc
Normal file
31
.eslintrc
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"indent": [
|
||||||
|
2,
|
||||||
|
4
|
||||||
|
],
|
||||||
|
"linebreak-style": [
|
||||||
|
2,
|
||||||
|
"unix"
|
||||||
|
],
|
||||||
|
"semi": [
|
||||||
|
2,
|
||||||
|
"always"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"es6": true,
|
||||||
|
"browser": true,
|
||||||
|
"node": true,
|
||||||
|
"mocha": true
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"modules": true
|
||||||
|
},
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 6,
|
||||||
|
"sourceType": "module"
|
||||||
|
}
|
||||||
|
}
|
||||||
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
*.log
|
||||||
|
/dist
|
||||||
14
index.html
Normal file
14
index.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<title>ES6 Boilerplate</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="main"></div>
|
||||||
|
<li></li>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="dist/bundle.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
35
package.json
Normal file
35
package.json
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"name": "backbone-es6",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Backbone JS es6 Template",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "npm-run-all --parallel dev:server lint:watch",
|
||||||
|
"dev:server": "webpack-dev-server --hot --inline",
|
||||||
|
"watch": "webpack -w -d",
|
||||||
|
"build": "webpack -p",
|
||||||
|
"lint": "node_modules/.bin/esw webpack.config.* src --color",
|
||||||
|
"lint:watch": "npm run lint -- --watch"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"es6"
|
||||||
|
],
|
||||||
|
"author": "Indrajith K L <mac91112@gmail.com>",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"babel-core": "^6.26.0",
|
||||||
|
"babel-loader": "^7.1.2",
|
||||||
|
"babel-preset-es2015": "^6.24.1",
|
||||||
|
"eslint": "^3.5.0",
|
||||||
|
"eslint-watch": "^2.1.14",
|
||||||
|
"npm-run-all": "^4.0.2",
|
||||||
|
"webpack": "^3.8.1",
|
||||||
|
"webpack-dev-server": "^2.9.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"backbone": "^1.3.3",
|
||||||
|
"jquery": "^3.2.1",
|
||||||
|
"mustache": "^2.3.0",
|
||||||
|
"underscore": "^1.8.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
13
src/index.js
Normal file
13
src/index.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import Backbone from 'backbone';
|
||||||
|
import TestView from './view';
|
||||||
|
import _ from 'underscore';
|
||||||
|
|
||||||
|
Backbone.history.start();
|
||||||
|
|
||||||
|
class Index {
|
||||||
|
constructor() {
|
||||||
|
new TestView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new Index();
|
||||||
26
src/myview.js
Normal file
26
src/myview.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import Backbone from 'backbone';
|
||||||
|
import * as _ from 'underscore';
|
||||||
|
import $ from 'jquery';
|
||||||
|
import Mustache from 'mustache';
|
||||||
|
|
||||||
|
|
||||||
|
export default class MyView extends Backbone.View {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
initialize() {
|
||||||
|
this.el = '#myarea';
|
||||||
|
this.$el = $(this.el);
|
||||||
|
this.template = 'Hello';
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
console.log(this.el)
|
||||||
|
this.$el.html(Mustache.render(this.template));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
28
src/view.js
Normal file
28
src/view.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import Backbone from 'backbone';
|
||||||
|
import * as _ from 'underscore';
|
||||||
|
import $ from 'jquery';
|
||||||
|
import Mustache from 'mustache';
|
||||||
|
import MyView from './myview';
|
||||||
|
|
||||||
|
|
||||||
|
export default class TestView extends Backbone.View {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
initialize() {
|
||||||
|
this.el = 'li';
|
||||||
|
this.$el = $(this.el);
|
||||||
|
this.template = '<div id="myarea"></div>'
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
console.log(this.el)
|
||||||
|
this.$el.html(Mustache.render(this.template));
|
||||||
|
new MyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
19
webpack.config.js
Normal file
19
webpack.config.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
module.exports = {
|
||||||
|
entry: __dirname + '/src/index.js',
|
||||||
|
output: {
|
||||||
|
path: __dirname + '/dist',
|
||||||
|
publicPath: '/dist/',
|
||||||
|
filename: 'bundle.js'
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [{
|
||||||
|
test: /\.js$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
use: 'babel-loader'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
devServer: {
|
||||||
|
contentBase: [ './' ],
|
||||||
|
watchContentBase: true
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user