Clean up

This commit is contained in:
syuilo 2017-02-27 02:51:38 +09:00
parent 9e9540e469
commit bb99368a47
5 changed files with 75 additions and 127 deletions

View File

@ -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,41 +122,16 @@ 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
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
)
);
ok();
}));
gulp.task('build:client:styles', () =>
gulp.src('./src/web/app/init.css')
.pipe(isProduction

View File

@ -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",

View File

@ -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

View File

@ -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);
}
}
});
});
};

View File

@ -1,9 +1,12 @@
/**
* 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 env = process.env.NODE_ENV;
const isProduction = env === 'production';
const pack: webpack.Configuration = {
@ -46,27 +49,20 @@ module.exports = (commit, env) => {
test: /\.styl$/,
exclude: /node_modules/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader'
},
{
loader: 'stylus-loader'
}
{ 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(),
new StringReplacePlugin()
],
output: {
filename: '[name]/script.js'
@ -74,10 +70,7 @@ module.exports = (commit, env) => {
};
if (isProduction) {
// TODO.
// see https://github.com/webpack/webpack/issues/2545
//pack.plugins.push(new Webpack.optimize.UglifyJsPlugin())
pack.plugins.push(new webpack.optimize.UglifyJsPlugin());
}
return pack;
};
module.exports = pack;