Skip to content

Commit 8871c0c

Browse files
committed
update
1 parent 1862d91 commit 8871c0c

File tree

7 files changed

+128
-0
lines changed

7 files changed

+128
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# IntelliJ project files
2+
.idea
3+
*.iml
4+
out
5+
gen

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = function(source) {
2+
return source.replace(/\\n\s*/g, '');
3+
};

package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "template-string-optimize-loader",
3+
"version": "0.0.1",
4+
"description": "template string optimize loader module for webpack",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "chenjiahan",
10+
"license": "ISC",
11+
"devDependencies": {
12+
"babel": "^6.3.26",
13+
"babel-loader": "^6.2.1",
14+
"babel-preset-es2015": "^6.3.13",
15+
"webpack": "^1.12.10"
16+
}
17+
}

test/dist/test.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/******/ (function(modules) { // webpackBootstrap
2+
/******/ // The module cache
3+
/******/ var installedModules = {};
4+
5+
/******/ // The require function
6+
/******/ function __webpack_require__(moduleId) {
7+
8+
/******/ // Check if module is in cache
9+
/******/ if(installedModules[moduleId])
10+
/******/ return installedModules[moduleId].exports;
11+
12+
/******/ // Create a new module (and put it into the cache)
13+
/******/ var module = installedModules[moduleId] = {
14+
/******/ exports: {},
15+
/******/ id: moduleId,
16+
/******/ loaded: false
17+
/******/ };
18+
19+
/******/ // Execute the module function
20+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21+
22+
/******/ // Flag the module as loaded
23+
/******/ module.loaded = true;
24+
25+
/******/ // Return the exports of the module
26+
/******/ return module.exports;
27+
/******/ }
28+
29+
30+
/******/ // expose the modules object (__webpack_modules__)
31+
/******/ __webpack_require__.m = modules;
32+
33+
/******/ // expose the module cache
34+
/******/ __webpack_require__.c = installedModules;
35+
36+
/******/ // __webpack_public_path__
37+
/******/ __webpack_require__.p = "";
38+
39+
/******/ // Load entry module and return exports
40+
/******/ return __webpack_require__(0);
41+
/******/ })
42+
/************************************************************************/
43+
/******/ ([
44+
/* 0 */
45+
/***/ function(module, exports) {
46+
47+
'use strict';
48+
49+
var template = function template(data) {
50+
return '<div><h3>' + data.title + '</h3><div>' + data.date + '</div><ul>' + data.list.map(function (item) {
51+
return '<li>' + item + '</li>';
52+
}).join('') + '</ul></div>';
53+
};
54+
55+
document.body.innerHTML = template({
56+
title: 'title',
57+
date: '2000-01-01',
58+
list: ['item1', 'item2']
59+
});
60+
61+
/***/ }
62+
/******/ ]);

test/src/test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const template = data => `
2+
<div>
3+
<h3>${data.title}</h3>
4+
<div>${data.date}</div>
5+
<ul>
6+
${data.list.map((item) => `
7+
<li>${item}</li>
8+
`).join('')}
9+
</ul>
10+
</div>
11+
`;
12+
13+
document.body.innerHTML = template({
14+
title : 'title',
15+
date : '2000-01-01',
16+
list : ['item1', 'item2']
17+
});

test/test.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Test</title>
6+
</head>
7+
<body>
8+
9+
<script src="dist/test.js"></script>
10+
</body>
11+
</html>

webpack.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
entry: "./test/src/test.js",
3+
output: {
4+
path: "test/dist",
5+
filename: "test.js"
6+
},
7+
module: {
8+
loaders: [
9+
// { test: /\.js$/, loader: "babel?presets[]=es2015"},
10+
{ test: /\.js$/, loader: "template-string-optimize!babel?presets[]=es2015"}
11+
]
12+
}
13+
};

0 commit comments

Comments
 (0)