Skip to content

Commit 26f200c

Browse files
author
dotos
committed
init
1 parent e1fb385 commit 26f200c

File tree

8 files changed

+219
-0
lines changed

8 files changed

+219
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
Thumbs.db
3+
db.json
4+
*.log
5+
node_modules/

dist/bundle.js

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/******/
2+
(function(modules) { // webpackBootstrap
3+
/******/ // The module cache
4+
/******/
5+
var installedModules = {};
6+
/******/
7+
/******/ // The require function
8+
/******/
9+
function __webpack_require__(moduleId) {
10+
/******/
11+
/******/ // Check if module is in cache
12+
/******/
13+
if (installedModules[moduleId]) {
14+
/******/
15+
return installedModules[moduleId].exports;
16+
/******/
17+
}
18+
/******/ // Create a new module (and put it into the cache)
19+
/******/
20+
var module = installedModules[moduleId] = {
21+
/******/
22+
i: moduleId,
23+
/******/
24+
l: false,
25+
/******/
26+
exports: {}
27+
/******/
28+
};
29+
/******/
30+
/******/ // Execute the module function
31+
/******/
32+
modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
33+
/******/
34+
/******/ // Flag the module as loaded
35+
/******/
36+
module.l = true;
37+
/******/
38+
/******/ // Return the exports of the module
39+
/******/
40+
return module.exports;
41+
/******/
42+
}
43+
/******/
44+
/******/
45+
/******/ // expose the modules object (__webpack_modules__)
46+
/******/
47+
__webpack_require__.m = modules;
48+
/******/
49+
/******/ // expose the module cache
50+
/******/
51+
__webpack_require__.c = installedModules;
52+
/******/
53+
/******/ // define getter function for harmony exports
54+
/******/
55+
__webpack_require__.d = function(exports, name, getter) {
56+
/******/
57+
if (!__webpack_require__.o(exports, name)) {
58+
/******/
59+
Object.defineProperty(exports, name, {
60+
/******/
61+
configurable: false,
62+
/******/
63+
enumerable: true,
64+
/******/
65+
get: getter
66+
/******/
67+
});
68+
/******/
69+
}
70+
/******/
71+
};
72+
/******/
73+
/******/ // getDefaultExport function for compatibility with non-harmony modules
74+
/******/
75+
__webpack_require__.n = function(module) {
76+
/******/
77+
var getter = module && module.__esModule ?
78+
/******/
79+
function getDefault() { return module['default']; } :
80+
/******/
81+
function getModuleExports() { return module; };
82+
/******/
83+
__webpack_require__.d(getter, 'a', getter);
84+
/******/
85+
return getter;
86+
/******/
87+
};
88+
/******/
89+
/******/ // Object.prototype.hasOwnProperty.call
90+
/******/
91+
__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
92+
/******/
93+
/******/ // __webpack_public_path__
94+
/******/
95+
__webpack_require__.p = "";
96+
/******/
97+
/******/ // Load entry module and return exports
98+
/******/
99+
return __webpack_require__(__webpack_require__.s = 0);
100+
/******/
101+
})
102+
/************************************************************************/
103+
/******/
104+
([
105+
/* 0 */
106+
/***/
107+
(function(module, exports, __webpack_require__) {
108+
109+
var msg = __webpack_require__(1);
110+
var app = document.getElementById('app');
111+
app.innerHTML = '<p>' + msg.hi + ',' + msg.event + "</p>";
112+
113+
/***/
114+
}),
115+
/* 1 */
116+
/***/
117+
(function(module, exports) {
118+
119+
module.exports = { hi: '您好呀', event: 'HEEEEE' };
120+
121+
/***/
122+
})
123+
/******/
124+
]);

index.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>Hello</title>
9+
</head>
10+
11+
<body>
12+
<div id="app"></div>
13+
<script src="./dist/bundle.js"></script>
14+
</body>
15+
16+
</html>

package.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "Valine",
3+
"version": "1.0.0",
4+
"description": "A simple comment system based on Leancloud.",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"build": "rimraf dist && webpack --watch",
9+
"dev": "node webpack.dev.server.js"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/xcss/Valine.git"
14+
},
15+
"keywords": [
16+
"Comment",
17+
"Valine"
18+
],
19+
"author": "xCss",
20+
"license": "ISC",
21+
"bugs": {
22+
"url": "https://github.com/xcss/Valine/issues"
23+
},
24+
"homepage": "https://github.com/xcss/Valine#readme",
25+
"dependencies": {
26+
"rimraf": "^2.6.1",
27+
"webpack": "^3.4.1",
28+
"webpack-dev-server": "^2.6.1"
29+
}
30+
}

src/js/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var msg = require('./message');
2+
var app = document.getElementById('app');
3+
app.innerHTML = '<p>' + msg.hi + ',' + msg.event + "</p>";
4+
5+
6+
if (module.hot) {
7+
// 启用热重载
8+
module.hot.accept();
9+
}

src/js/message.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { hi: '你是谁', event: 'HEEEExxEEEEEEEEEEEEEx' };

webpack.config.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var path = require('path');
2+
var webpack = require('webpack');
3+
module.exports = {
4+
// 入口文件
5+
entry: [
6+
'./src/js/index.js',
7+
'webpack/hot/dev-server', // 调用热重载hot
8+
'webpack-dev-server/client?http://localhost:8080' // 添加webpack-dev-server客户端
9+
],
10+
output: {
11+
path: path.join(__dirname, 'dist'), // 指定打包后的目录
12+
publicPath: 'dist', // 指定资源文件引用的目录
13+
filename: 'bundle.js' // 指定打包为一个文件 bundle.js
14+
},
15+
plugins: [
16+
// 全局开启热代码替换
17+
new webpack.HotModuleReplacementPlugin()
18+
]
19+
}

webpack.dev.server.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var WebpackDevServer = require('webpack-dev-server');
2+
var webpack = require('webpack');
3+
var config = require('./webpack.config');
4+
var path = require('path');
5+
var compiler = webpack(config);
6+
// 创建服务器实例
7+
var server = new WebpackDevServer(compiler, {
8+
hot: true,
9+
filename: config.output.filename,
10+
publicPath: config.output.publicPath,
11+
stats: {
12+
colors: true
13+
}
14+
});
15+
server.listen(8080, 'localhost', function() {});

0 commit comments

Comments
 (0)