Clean up

This commit is contained in:
syuilo 2017-02-27 02:51:38 +09:00
parent f565122c4c
commit 134be39d38
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 cssnano = require('gulp-cssnano');
import * as uglify from 'gulp-uglify'; import * as uglify from 'gulp-uglify';
import pug = require('gulp-pug'); import pug = require('gulp-pug');
import git = require('git-last-commit');
import * as rimraf from 'rimraf'; import * as rimraf from 'rimraf';
import prominence = require('prominence');
import * as chalk from 'chalk'; import * as chalk from 'chalk';
import imagemin = require('gulp-imagemin'); import imagemin = require('gulp-imagemin');
import * as rename from 'gulp-rename'; import * as rename from 'gulp-rename';
@ -56,9 +54,6 @@ gulp.task('build:ts', () =>
tsProject tsProject
.src() .src()
.pipe(tsProject()) .pipe(tsProject())
.pipe(babel({
presets: ['es2015', 'stage-3']
}))
.pipe(gulp.dest('./built/')) .pipe(gulp.dest('./built/'))
); );
@ -127,40 +122,15 @@ gulp.task('build:client', [
'copy:client' 'copy:client'
]); ]);
gulp.task('build:client:scripts', () => new Promise(async (ok) => { gulp.task('build:client:scripts', () =>
// 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());
}
es.merge( es.merge(
stream.pipe(gulp.dest('./built/web/resources/')) as any, webpack(require('./webpack.config'), require('webpack'))
entryPointStream.pipe(gulp.dest('./built/web/resources/client/')) as any .pipe(gulp.dest('./built/web/resources/')) as any,
); gulp.src('./src/web/app/client/script.js')
.pipe(isProduction ? uglify() : gutil.noop())
ok(); .pipe(gulp.dest('./built/web/resources/client/')) as any
})); )
);
gulp.task('build:client:styles', () => gulp.task('build:client:styles', () =>
gulp.src('./src/web/app/init.css') gulp.src('./src/web/app/init.css')

View file

@ -88,7 +88,6 @@
"express": "4.14.1", "express": "4.14.1",
"file-type": "4.1.0", "file-type": "4.1.0",
"fuckadblock": "3.2.1", "fuckadblock": "3.2.1",
"git-last-commit": "0.2.0",
"glob": "7.1.1", "glob": "7.1.1",
"gm": "1.23.0", "gm": "1.23.0",
"gulp": "3.9.1", "gulp": "3.9.1",
@ -140,6 +139,7 @@
"ts-node": "2.1.0", "ts-node": "2.1.0",
"tslint": "4.4.2", "tslint": "4.4.2",
"typescript": "2.2.1", "typescript": "2.2.1",
"uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony",
"uuid": "3.0.1", "uuid": "3.0.1",
"velocity-animate": "1.4.3", "velocity-animate": "1.4.3",
"vhost": "3.0.2", "vhost": "3.0.2",

View file

@ -8,7 +8,6 @@ const api = require('./common/scripts/api');
const signout = require('./common/scripts/signout'); const signout = require('./common/scripts/signout');
const generateDefaultUserdata = require('./common/scripts/generate-default-userdata'); const generateDefaultUserdata = require('./common/scripts/generate-default-userdata');
const mixins = require('./common/mixins'); const mixins = require('./common/mixins');
const checkForUpdate = require('./common/scripts/check-for-update');
require('./common/tags'); require('./common/tags');
/** /**
@ -50,9 +49,6 @@ try {
Storage.prototype.setItem = () => { }; // noop Storage.prototype.setItem = () => { }; // noop
} }
// Check for Update
checkForUpdate();
// ユーザーをフェッチしてコールバックする // ユーザーをフェッチしてコールバックする
module.exports = callback => { module.exports = callback => {
// Get cached account data // 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,83 +1,76 @@
/**
* webpack config
*/
import * as webpack from 'webpack'; import * as webpack from 'webpack';
const StringReplacePlugin = require('string-replace-webpack-plugin'); const StringReplacePlugin = require('string-replace-webpack-plugin');
const constants = require('./src/const.json'); const constants = require('./src/const.json');
module.exports = (commit, env) => { const env = process.env.NODE_ENV;
const isProduction = env === 'production'; const isProduction = env === 'production';
const pack: webpack.Configuration = { const pack: webpack.Configuration = {
entry: { entry: {
'desktop': './src/web/app/desktop/script.js', 'desktop': './src/web/app/desktop/script.js',
'mobile': './src/web/app/mobile/script.js', 'mobile': './src/web/app/mobile/script.js',
'dev': './src/web/app/dev/script.js', 'dev': './src/web/app/dev/script.js',
'auth': './src/web/app/auth/script.js' 'auth': './src/web/app/auth/script.js'
}, },
module: { module: {
rules: [ rules: [
{ {
enforce: 'pre', enforce: 'pre',
test: /\.tag$/, test: /\.tag$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: StringReplacePlugin.replace({ loader: StringReplacePlugin.replace({
replacements: [ replacements: [
{ pattern: /\$theme\-color\-foreground/g, replacement: () => constants.themeColorForeground }, { pattern: /\$theme\-color\-foreground/g, replacement: () => constants.themeColorForeground },
{ pattern: /\$theme\-color/g, replacement: () => constants.themeColor }, { pattern: /\$theme\-color/g, replacement: () => constants.themeColor },
] ]
}) })
}, },
{ {
test: /\.tag$/, test: /\.tag$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: 'riot-tag-loader', loader: 'riot-tag-loader',
query: { query: {
hot: false, hot: false,
style: 'stylus', style: 'stylus',
expr: false, expr: false,
compact: true, compact: true,
parserOptions: { parserOptions: {
style: { style: {
compress: true compress: true
}
} }
} }
},
{
test: /\.styl$/,
exclude: /node_modules/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader'
},
{
loader: 'stylus-loader'
}
]
} }
] },
}, {
plugins: [ test: /\.styl$/,
new webpack.DefinePlugin({ exclude: /node_modules/,
VERSION: JSON.stringify(commit ? commit.hash : null), use: [
CONFIG: { { loader: 'style-loader' },
themeColor: JSON.stringify(constants.themeColor) { loader: 'css-loader' },
} { loader: 'stylus-loader' }
}), ]
new StringReplacePlugin(), }
], ]
output: { },
filename: '[name]/script.js' plugins: [
} new webpack.DefinePlugin({
}; CONFIG: {
themeColor: JSON.stringify(constants.themeColor)
if (isProduction) { }
// TODO. }),
// see https://github.com/webpack/webpack/issues/2545 new StringReplacePlugin()
//pack.plugins.push(new Webpack.optimize.UglifyJsPlugin()) ],
output: {
filename: '[name]/script.js'
} }
return pack;
}; };
if (isProduction) {
pack.plugins.push(new webpack.optimize.UglifyJsPlugin());
}
module.exports = pack;