Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
dotos committed Aug 3, 2017
1 parent e1fb385 commit 26f200c
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
Thumbs.db
db.json
*.log
node_modules/
124 changes: 124 additions & 0 deletions dist/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/******/
(function(modules) { // webpackBootstrap
/******/ // The module cache
/******/
var installedModules = {};
/******/
/******/ // The require function
/******/
function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/
if (installedModules[moduleId]) {
/******/
return installedModules[moduleId].exports;
/******/
}
/******/ // Create a new module (and put it into the cache)
/******/
var module = installedModules[moduleId] = {
/******/
i: moduleId,
/******/
l: false,
/******/
exports: {}
/******/
};
/******/
/******/ // Execute the module function
/******/
modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/
module.l = true;
/******/
/******/ // Return the exports of the module
/******/
return module.exports;
/******/
}
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/
__webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/
__webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/
__webpack_require__.d = function(exports, name, getter) {
/******/
if (!__webpack_require__.o(exports, name)) {
/******/
Object.defineProperty(exports, name, {
/******/
configurable: false,
/******/
enumerable: true,
/******/
get: getter
/******/
});
/******/
}
/******/
};
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/
__webpack_require__.n = function(module) {
/******/
var getter = module && module.__esModule ?
/******/
function getDefault() { return module['default']; } :
/******/
function getModuleExports() { return module; };
/******/
__webpack_require__.d(getter, 'a', getter);
/******/
return getter;
/******/
};
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/
__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/
__webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/
return __webpack_require__(__webpack_require__.s = 0);
/******/
})
/************************************************************************/
/******/
([
/* 0 */
/***/
(function(module, exports, __webpack_require__) {

var msg = __webpack_require__(1);
var app = document.getElementById('app');
app.innerHTML = '<p>' + msg.hi + ',' + msg.event + "</p>";

/***/
}),
/* 1 */
/***/
(function(module, exports) {

module.exports = { hi: '您好呀', event: 'HEEEEE' };

/***/
})
/******/
]);
16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Hello</title>
</head>

<body>
<div id="app"></div>
<script src="./dist/bundle.js"></script>
</body>

</html>
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "Valine",
"version": "1.0.0",
"description": "A simple comment system based on Leancloud.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rimraf dist && webpack --watch",
"dev": "node webpack.dev.server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/xcss/Valine.git"
},
"keywords": [
"Comment",
"Valine"
],
"author": "xCss",
"license": "ISC",
"bugs": {
"url": "https://github.com/xcss/Valine/issues"
},
"homepage": "https://github.com/xcss/Valine#readme",
"dependencies": {
"rimraf": "^2.6.1",
"webpack": "^3.4.1",
"webpack-dev-server": "^2.6.1"
}
}
9 changes: 9 additions & 0 deletions src/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var msg = require('./message');
var app = document.getElementById('app');
app.innerHTML = '<p>' + msg.hi + ',' + msg.event + "</p>";


if (module.hot) {
// 启用热重载
module.hot.accept();
}
1 change: 1 addition & 0 deletions src/js/message.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { hi: '你是谁', event: 'HEEEExxEEEEEEEEEEEEEx' };
19 changes: 19 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var path = require('path');
var webpack = require('webpack');
module.exports = {
// 入口文件
entry: [
'./src/js/index.js',
'webpack/hot/dev-server', // 调用热重载hot
'webpack-dev-server/client?http://localhost:8080' // 添加webpack-dev-server客户端
],
output: {
path: path.join(__dirname, 'dist'), // 指定打包后的目录
publicPath: 'dist', // 指定资源文件引用的目录
filename: 'bundle.js' // 指定打包为一个文件 bundle.js
},
plugins: [
// 全局开启热代码替换
new webpack.HotModuleReplacementPlugin()
]
}
15 changes: 15 additions & 0 deletions webpack.dev.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var WebpackDevServer = require('webpack-dev-server');
var webpack = require('webpack');
var config = require('./webpack.config');
var path = require('path');
var compiler = webpack(config);
// 创建服务器实例
var server = new WebpackDevServer(compiler, {
hot: true,
filename: config.output.filename,
publicPath: config.output.publicPath,
stats: {
colors: true
}
});
server.listen(8080, 'localhost', function() {});

0 comments on commit 26f200c

Please sign in to comment.