Permalink
Browse files

とりあえず、JavaScriptのモジュール化の準備

  • Loading branch information...
1 parent 798ad3e commit b9e7ba59d6f5ab8f12330f92b43340db5ba5b49f @logue committed Jul 7, 2016
Showing with 93 additions and 51 deletions.
  1. +2 −3 bower.json
  2. +7 −1 composer.json
  3. +9 −8 config.rb
  4. +33 −19 gulpfile.js
  5. +28 −18 package.json
  6. +7 −0 webroot/sources/js/app.js
  7. +7 −2 webroot/sources/scss/pukiwiki.scss
View
@@ -4,12 +4,11 @@
"dependencies": {
"autosize": "~3.*",
"bootstrap": "~4.*",
+ "js-cookie": "2.1.*",
"fontawesome": "~4.*",
- "jquery": "~2.*",
+ "jquery": "~3.*",
"jquery-form": "~3.*",
"jquery-mobile": "~1.4.*",
- "jquery-ui": "~1.11.*",
- "jquery.cookie": "~1.*",
"jquery.taboverride": "4.0.0",
"modernizr": "~3.*",
"superfish": "~1.*"
View
@@ -65,5 +65,11 @@
"type": "composer",
"url": "https://packages.zendframework.com/"
}
- ]
+ ],
+ "scripts": {
+ "post-update-cmd": [
+ "composer dump-autoload -o",
+ "gulp"
+ ]
+ }
}
View
@@ -1,16 +1,17 @@
+# coala用Scssの設定
require 'compass/import-once/activate'
# Require any additional compass plugins here.
-http_path = "webroot"
-css_dir = "./webroot/assets/css"
-sass_dir = "./webroot/sources/scss"
-images_dir = "./webroot/sources/images"
-javascripts_dir = "./webroot/assets/js"
-fonts_dir = "./webroot/assets/fonts"
+http_path = "/"
+css_dir = "webroot/assets/css"
+sass_dir = "webroot/sources/scss"
+images_dir = "webroot/sources/images"
+javascripts_dir = "webroot/assets/js"
+fonts_dir = "webroot/assets/fonts"
additional_import_paths = [
- './webroot/sources/bower_components/bootstrap/scss',
- './webroot/sources/bower_components/fontawesome/scss'
+ 'webroot/sources/bower_components/bootstrap/scss',
+ 'webroot/sources/bower_components/fontawesome/scss'
]
sass_options = {:unix_newlines => true}
output_style = :compressed
View
@@ -2,19 +2,22 @@
// 使用するプラグイン
var
+ babelify = require("babelify"),
bower = require('gulp-bower'),
+ browserify = require("browserify"),
compass = require('gulp-compass'),
composer = require('gulp-composer'),
concat = require('gulp-concat'),
del = require('del'),
gulp = require('gulp'),
gulpFilter = require('gulp-filter'),
install = require("gulp-install"),
- notify = require("gulp-notify"),
modernizr = require('gulp-modernizr'),
+ notify = require("gulp-notify"),
plumber = require("gulp-plumber"),
rename = require('gulp-rename'),
sass = require('gulp-ruby-sass'),
+ source = require("vinyl-source-stream"),
uglify = require("gulp-uglify")
;
// 初期設定
@@ -42,20 +45,15 @@ gulp.task('setup', ['clean'], function () {
;
});
-// JavaScriptを結合
-gulp.task('js.concat', function() {
- return gulp.src(config.jsSrcPath + '*.js')
- .pipe(plumber())
- .pipe(concat('pukiwiki.js'))
- .pipe(gulp.dest(config.jsPath))
- ;
-});
// JavaScriptを圧縮
-gulp.task('js.uglify', ['js.concat'], function() {
- return gulp.src(config.jsPath + 'pukiwiki.js')
+gulp.task('js.uglify', function() {
+ return gulp.src(config.jsSrcPath + 'app.js')
.pipe(plumber())
- .pipe(uglify({preserveComments: 'some'}))
- .pipe(rename('pukiwiki.min.js'))
+ .pipe(uglify({
+ preserveComments: 'some',
+ preserveComments: 'license' // ライセンスを残す
+ }))
+ .pipe(rename('app.min.js'))
.pipe(gulp.dest(config.jsPath))
;
});
@@ -69,9 +67,25 @@ gulp.task('js.modernizr', function() {
;
})
-// JavaScript関係の処理
-gulp.task('js', ['js.concat', 'js.uglify', 'js.modernizr']);
+// ES6で書かれたjsを通常のjsに変換
+gulp.task('js.babelify', function () {
+ browserify({
+ entries: "./webroot/sources/js/app.js",
+ extensions: [".js"]
+ })
+ .plugin('licensify')
+ .transform(babelify, {presets: ['es2015']})
+ .bundle()
+ .on("error", function (err) {
+ console.log("Error : " + err.message);
+ this.emit("end");
+ })
+ .pipe(source("app.js"))
+ .pipe(gulp.dest("./webroot/assets/js"));
+});
+// JavaScript関係の処理
+gulp.task('js', ['js.babelify', 'js.uglify', 'js.modernizr']);
// アイコンフォント
gulp.task('icons', function() {
@@ -105,8 +119,8 @@ gulp.task('watch', function() {
});
// Composerを実行
-gulp.task('composer', function () {
- composer();
-});
+gulp.task("composer", function () {
+ composer({ "self-install": false });
+})
-gulp.task('default', ['composer','icons', 'css', 'js']);
+gulp.task('default', ['icons', 'css', 'js']);
View
@@ -7,34 +7,44 @@
"doc": "doc"
},
"devDependencies": {
- "browserify": "^11.2.0",
- "del": "^2.1.0",
- "gulp": "^3.9.0",
- "gulp-bower": "0.0.10",
+ "browserify": "^13.*.*",
+ "del": "^2.2.*",
+ "gulp": "^3.9.1",
+ "gulp-bower": "0.0.*",
"gulp-bower-files": "^0.2.7",
"gulp-compass": "^2.1.0",
- "gulp-composer": "^0.1.0",
- "gulp-concat": "^2.6.0",
- "gulp-filter": "^3.0.1",
- "gulp-install": "^0.5.0",
- "gulp-modernizr": "0.0.0",
- "gulp-notify": "^2.2.0",
- "gulp-plumber": "^1.0.1",
- "gulp-rename": "^1.2.2",
- "gulp-ruby-sass": "^2.0.3",
- "gulp-sourcemaps": "^1.6.0",
- "gulp-uglify": "^1.5.1",
- "main-bower-files": "^2.9.0",
- "vinyl-source-stream": "^1.1.0"
+ "gulp-composer": "^0.4.*",
+ "gulp-concat": "^2.6.*",
+ "gulp-filter": "^4.0.*",
+ "gulp-install": "^0.6.*",
+ "gulp-modernizr": "1.0.0-alpha",
+ "gulp-notify": "^2.2.*",
+ "gulp-plumber": "^1.1.*",
+ "gulp-rename": "^1.2.*",
+ "gulp-ruby-sass": "^2.0.*",
+ "gulp-sourcemaps": "^1.6.*",
+ "gulp-uglify": "^1.5.*",
+ "licensify": "^3.1.2",
+ "main-bower-files": "^2.13.*",
+ "vinyl-source-stream": "^1.1.*"
},
"scripts": {
"start": "gulp",
- "test": "echo \"Error: no test specified\" && exit 1"
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "build:js": "browserify ./webroot/source/js/app.js -t babelify --outfile ./webroot/assets/js/app.js"
},
"repository": {
"type": "git",
"url": "https://github.com/logue/pukiwiki_adv.git"
},
+ "browserify": {
+ "transform": [
+ "browserify-shim"
+ ]
+ },
+ "browserify-shim": {
+ "jquery": "$"
+ },
"keywords": [
"wiki",
"pukiwiki"
@@ -0,0 +1,7 @@
+'use strict';
+
+import 'jquery'
+import bs from '../bower_components/bootstrap/dist/js/bootstrap.min';
+
+window.$ = $;
+window.bs = bs;
@@ -2,7 +2,7 @@
* PukiWiki Advance - Yet another WikiWikiWeb clone.
* PukiWiki Advance Standard Stylesheet set
*
- * Copyright (c)2010-2015 PukiWiki Advance Developer Team <http://pukiwiki.logue.be/>
+ * Copyright (c)2010-2016 PukiWiki Advance Developer Team <http://pukiwiki.logue.be/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,11 +24,16 @@
@import "bootstrap";
@import "font-awesome";
+/*!
+ * PukiWiki base stylesheet start
+ */
@import 'components/browser';
@import 'components/table';
@import 'components/tweeks';
@import 'components/plugin';
-
+/*!
+ * PukiWiki widgets stylesheet start
+ */
@import 'components/widgets';
@import 'components/widgets-dataTables';
@import 'components/widgets-google-search';

0 comments on commit b9e7ba5

Please sign in to comment.