Skip to content

Commit 7641219

Browse files
committed
コンパイル不能になっていた環境を整備
ビルド環境を最新化(webpack 3→4, babel 6→7等)
1 parent 830cb9f commit 7641219

9 files changed

Lines changed: 5775 additions & 5933 deletions

File tree

html-build/package-lock.json

Lines changed: 5715 additions & 5873 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

html-build/package.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@
99
"author": "",
1010
"license": "MIT",
1111
"devDependencies": {
12-
"autoprefixer": "^8.0.0",
13-
"babel-core": "^6.26.0",
14-
"babel-loader": "^7.1.2",
15-
"babel-preset-env": "^1.6.1",
16-
"css-loader": "^0.28.9",
17-
"cssnano": "^3.10.0",
18-
"node-sass": "^4.7.2",
19-
"postcss-loader": "^2.1.0",
20-
"prettier": "^1.10.2",
21-
"sass-loader": "^6.0.6",
22-
"style-loader": "^0.20.2",
23-
"url-loader": "^0.6.2",
24-
"webpack": "^3.11.0"
12+
"autoprefixer": "^9.4.4",
13+
"@babel/core": "^7.2.2",
14+
"@babel/preset-env": "^7.2.3",
15+
"babel-loader": "^8.0.5",
16+
"css-loader": "^2.1.0",
17+
"cssnano": "^4.1.8",
18+
"node-sass": "^4.11.0",
19+
"postcss-loader": "^3.0.0",
20+
"prettier": "^1.15.3",
21+
"sass-loader": "^7.1.0",
22+
"style-loader": "^0.23.1",
23+
"url-loader": "^1.1.2",
24+
"webpack": "^4.28.3",
25+
"webpack-cli": "^3.2.1"
2526
},
2627
"dependencies": {
2728
"jquery": "^3.3.1",

html-build/src/style/highlight.js/atom-one-dark.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.theme-dark {
2-
.hljs {
2+
.language-js {
33
display: block;
44
overflow-x: auto;
55
padding: 0.5em;

html-build/src/style/highlight.js/atom-one-light.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
.theme-light {
3-
.hljs {
3+
.language-js {
44
display: block;
55
overflow-x: auto;
66
padding: 0.5em;

html-build/webpack.config.js

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
const webpack = require('webpack');
2-
31
const isProduction = true;
4-
const useOptimize = isProduction;
52
const useSourceMap = !isProduction;
63

74
module.exports = {
5+
mode: isProduction ? 'production' : 'development',
86
entry: './src/main.js',
97
output: { // ファイルの出力設定
108
path: `${__dirname}/../html/js`, // 出力ファイルのディレクトリ名
11-
filename: 'bundle.js' // 出力ファイル名
9+
filename: 'bundle.js', // 出力ファイル名
1210
},
1311
module: {
1412
rules: [
@@ -22,13 +20,11 @@ module.exports = {
2220
// Babel のオプションを指定する
2321
options: {
2422
presets: [
25-
// env を指定することで、ES2017 を ES5 に変換。
26-
// {modules: false}にしないと import 文が Babel によって CommonJS に変換され、
27-
// webpack の Tree Shaking 機能が使えない
28-
['env', {'modules': false}]
29-
]
30-
}
31-
}
23+
// プリセットを指定することで、ES2018 を ES5 に変換
24+
'@babel/preset-env',
25+
],
26+
},
27+
},
3228
],
3329
// node_modules は除外する
3430
exclude: /node_modules/,
@@ -46,7 +42,7 @@ module.exports = {
4642
url: true,
4743
// ソースマップを有効にする
4844
sourceMap: useSourceMap,
49-
importLoaders: 2
45+
importLoaders: 2,
5046
},
5147
},
5248
{
@@ -62,27 +58,13 @@ module.exports = {
6258
// 画像関係
6359
{
6460
test: /\.(png|jpeg|svg)$/,
65-
use: 'url-loader'
61+
use: 'url-loader',
6662
},
6763
// フォント関係
6864
{
6965
test: /\.(otf|eot|svg|ttf|woff|woff2)(\?.+)?$/,
70-
use: 'url-loader'
71-
}
66+
use: 'url-loader',
67+
},
7268
],
7369
},
74-
plugins: useOptimize === true ? [
75-
// 【効果:中】Scope Hoistingをするためのプラグイン
76-
new webpack.optimize.ModuleConcatenationPlugin(),
77-
78-
// 【効果:大】JSファイルのminifyを実行する
79-
new webpack.optimize.UglifyJsPlugin({
80-
sourceMap: useSourceMap,
81-
compress: {
82-
warnings: false,
83-
},
84-
// マルチプロセスで高速化
85-
parallel: true,
86-
}),
87-
] : []
8870
};

html/js/bundle.js

Lines changed: 24 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tool-generate-htmls/index.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const htmlMinifier = require('html-minifier');
77
let promises = [];
88
let samplesUrl = 'https://ics-creative.github.io/tutorial-three/';
99
let samplesHtmlUrl = 'https://github.com/ics-creative/tutorial-three/blob/master/';
10-
let templateHtml;
10+
const templateHtml = fs.readFileSync('./template-html.html', 'utf8');
1111

1212
/**
1313
* テンプレート文字列を展開
@@ -100,7 +100,8 @@ const generateHTML = (dirName, fileName, resolve) => {
100100
// --------------------------------
101101
// メタデータの選定
102102
// --------------------------------
103-
const articleAuthorArr = articleMarkdown.match(/<p><article-author>(.*?)<\/article-author><\/p>/);
103+
104+
const articleAuthorArr = articleMarkdown.match(/<article-author>(.*?)<\/article-author>/);
104105
const articleAuthorStr = articleAuthorArr ? articleAuthorArr[1] : '';
105106
if (!articleAuthorArr) {
106107
console.error(`<article-author> Element is not written. : ${fileName}`);
@@ -153,7 +154,7 @@ const generateHTML = (dirName, fileName, resolve) => {
153154
'url': url
154155
};
155156
if (!templateHtml) {
156-
console.log(fileName + ' generate error!');
157+
console.error(fileName + ' generate error! templateHtml is empty.');
157158
return;
158159
}
159160

@@ -192,12 +193,7 @@ fs.readdir('../docs', (err, files) => {
192193
}
193194
});
194195
}));
195-
promises.push(new Promise((resolve) => {
196-
fs.readFile('template-html.html', 'utf8', (error, text) => {
197-
templateHtml = text;
198-
resolve();
199-
});
200-
}));
196+
201197
for (let i = 0; i < files.length; i++) {
202198
const filename = files[i];
203199
const childPromise = new Promise((resolve) => {

tool-generate-htmls/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"build": "node index.js"
44
},
55
"devDependencies": {
6-
"highlight.js": "^9.12.0",
7-
"html-minifier": "^3.5.9",
8-
"marked": "^0.3.16",
6+
"highlight.js": "^9.13.1",
7+
"html-minifier": "^3.5.21",
8+
"marked": "^0.6.0",
99
"mkdirp": "^0.5.1"
1010
},
1111
"dependencies": {},

tool-generate-htmls/template-html.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<meta name="date" content="${article-dateModified}T00:00:00+09:00"/>
2727

2828
<link rel="icon" sizes="16x16 32x32 48x48 128x128 256x256" href="https://ics.media/wp-content/themes/icslab/img/favicon.ico"/>
29-
<script src="js/bundle.js?v=2018-02-23_b"></script>
29+
<script src="js/bundle.js?v=2019-01-08_01"></script>
3030
</head>
3131
<body class="tutorial theme-light">
3232

0 commit comments

Comments
 (0)