diff --git a/gulpfile.ts b/gulpfile.ts index f4f0753b4e..08fdc7ec06 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -15,9 +15,7 @@ import * as webpack from 'webpack-stream'; import cssnano = require('gulp-cssnano'); import * as uglify from 'gulp-uglify'; import pug = require('gulp-pug'); -import git = require('git-last-commit'); import * as rimraf from 'rimraf'; -import prominence = require('prominence'); import * as chalk from 'chalk'; import imagemin = require('gulp-imagemin'); import * as rename from 'gulp-rename'; @@ -56,9 +54,6 @@ gulp.task('build:ts', () => tsProject .src() .pipe(tsProject()) - .pipe(babel({ - presets: ['es2015', 'stage-3'] - })) .pipe(gulp.dest('./built/')) ); @@ -127,40 +122,15 @@ gulp.task('build:client', [ 'copy:client' ]); -gulp.task('build:client:scripts', () => new Promise(async (ok) => { - // Get commit info - const commit = await prominence(git).getLastCommit(); - - let stream = webpack(require('./webpack.config')(commit, env), require('webpack')); - - // TODO: remove this block - if (isProduction) { - stream = stream - // ↓ https://github.com/mishoo/UglifyJS2/issues/448 - .pipe(babel({ - presets: ['es2015'] - })) - .pipe(uglify()); - } - - let entryPointStream = gulp.src('./src/web/app/client/script.js'); - - if (isProduction) { - entryPointStream = entryPointStream - // ↓ https://github.com/mishoo/UglifyJS2/issues/448 - .pipe(babel({ - presets: ['es2015'] - })) - .pipe(uglify()); - } - +gulp.task('build:client:scripts', () => es.merge( - stream.pipe(gulp.dest('./built/web/resources/')) as any, - entryPointStream.pipe(gulp.dest('./built/web/resources/client/')) as any - ); - - ok(); -})); + webpack(require('./webpack.config'), require('webpack')) + .pipe(gulp.dest('./built/web/resources/')) as any, + gulp.src('./src/web/app/client/script.js') + .pipe(isProduction ? uglify() : gutil.noop()) + .pipe(gulp.dest('./built/web/resources/client/')) as any + ) +); gulp.task('build:client:styles', () => gulp.src('./src/web/app/init.css') diff --git a/package.json b/package.json index e3470e2fc0..78b1ca23a3 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,6 @@ "express": "4.14.1", "file-type": "4.1.0", "fuckadblock": "3.2.1", - "git-last-commit": "0.2.0", "glob": "7.1.1", "gm": "1.23.0", "gulp": "3.9.1", @@ -140,6 +139,7 @@ "ts-node": "2.1.0", "tslint": "4.4.2", "typescript": "2.2.1", + "uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony", "uuid": "3.0.1", "velocity-animate": "1.4.3", "vhost": "3.0.2", diff --git a/src/web/app/boot.js b/src/web/app/boot.js index 0b963c40c1..f546cd8176 100644 --- a/src/web/app/boot.js +++ b/src/web/app/boot.js @@ -8,7 +8,6 @@ const api = require('./common/scripts/api'); const signout = require('./common/scripts/signout'); const generateDefaultUserdata = require('./common/scripts/generate-default-userdata'); const mixins = require('./common/mixins'); -const checkForUpdate = require('./common/scripts/check-for-update'); require('./common/tags'); /** @@ -50,9 +49,6 @@ try { Storage.prototype.setItem = () => { }; // noop } -// Check for Update -checkForUpdate(); - // ユーザーをフェッチしてコールバックする module.exports = callback => { // Get cached account data diff --git a/src/web/app/common/scripts/check-for-update.js b/src/web/app/common/scripts/check-for-update.js deleted file mode 100644 index cd7279e3b8..0000000000 --- a/src/web/app/common/scripts/check-for-update.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = () => { - fetch('/api:meta').then(res => { - res.json().then(meta => { - if (meta.commit.hash !== VERSION) { - if (window.confirm('新しいMisskeyのバージョンがあります。更新しますか?\r\n(このメッセージが繰り返し表示される場合は、サーバーにデータがまだ届いていない可能性があるので、少し時間を置いてから再度お試しください)')) { - location.reload(true); - } - } - }); - }); -}; diff --git a/webpack.config.ts b/webpack.config.ts index 9e49867539..0fdc5aec50 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -1,83 +1,76 @@ +/** + * webpack config + */ + import * as webpack from 'webpack'; const StringReplacePlugin = require('string-replace-webpack-plugin'); - const constants = require('./src/const.json'); -module.exports = (commit, env) => { - const isProduction = env === 'production'; +const env = process.env.NODE_ENV; +const isProduction = env === 'production'; - const pack: webpack.Configuration = { - entry: { - 'desktop': './src/web/app/desktop/script.js', - 'mobile': './src/web/app/mobile/script.js', - 'dev': './src/web/app/dev/script.js', - 'auth': './src/web/app/auth/script.js' - }, - module: { - rules: [ - { - enforce: 'pre', - test: /\.tag$/, - exclude: /node_modules/, - loader: StringReplacePlugin.replace({ - replacements: [ - { pattern: /\$theme\-color\-foreground/g, replacement: () => constants.themeColorForeground }, - { pattern: /\$theme\-color/g, replacement: () => constants.themeColor }, - ] - }) - }, - { - test: /\.tag$/, - exclude: /node_modules/, - loader: 'riot-tag-loader', - query: { - hot: false, - style: 'stylus', - expr: false, - compact: true, - parserOptions: { - style: { - compress: true - } +const pack: webpack.Configuration = { + entry: { + 'desktop': './src/web/app/desktop/script.js', + 'mobile': './src/web/app/mobile/script.js', + 'dev': './src/web/app/dev/script.js', + 'auth': './src/web/app/auth/script.js' + }, + module: { + rules: [ + { + enforce: 'pre', + test: /\.tag$/, + exclude: /node_modules/, + loader: StringReplacePlugin.replace({ + replacements: [ + { pattern: /\$theme\-color\-foreground/g, replacement: () => constants.themeColorForeground }, + { pattern: /\$theme\-color/g, replacement: () => constants.themeColor }, + ] + }) + }, + { + test: /\.tag$/, + exclude: /node_modules/, + loader: 'riot-tag-loader', + query: { + hot: false, + style: 'stylus', + expr: false, + compact: true, + parserOptions: { + style: { + compress: true } } - }, - { - test: /\.styl$/, - exclude: /node_modules/, - use: [ - { - loader: 'style-loader' - }, - { - loader: 'css-loader' - }, - { - loader: 'stylus-loader' - } - ] } - ] - }, - plugins: [ - new webpack.DefinePlugin({ - VERSION: JSON.stringify(commit ? commit.hash : null), - CONFIG: { - themeColor: JSON.stringify(constants.themeColor) - } - }), - new StringReplacePlugin(), - ], - output: { - filename: '[name]/script.js' - } - }; - - if (isProduction) { - // TODO. - // see https://github.com/webpack/webpack/issues/2545 - //pack.plugins.push(new Webpack.optimize.UglifyJsPlugin()) + }, + { + test: /\.styl$/, + exclude: /node_modules/, + use: [ + { loader: 'style-loader' }, + { loader: 'css-loader' }, + { loader: 'stylus-loader' } + ] + } + ] + }, + plugins: [ + new webpack.DefinePlugin({ + CONFIG: { + themeColor: JSON.stringify(constants.themeColor) + } + }), + new StringReplacePlugin() + ], + output: { + filename: '[name]/script.js' } - - return pack; }; + +if (isProduction) { + pack.plugins.push(new webpack.optimize.UglifyJsPlugin()); +} + +module.exports = pack;