Skip to content

Commit

Permalink
developではバージョンにノイズを付加するように
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Feb 20, 2021
1 parent c76e8dd commit be12a83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"migrateandstart": "npm run migrate && npm run start",
"build": "webpack && gulp build",
"webpack": "webpack",
"watch": "webpack --watch",
"gulp": "gulp build",
"clean": "gulp clean",
"cleanall": "gulp cleanall",
Expand Down
13 changes: 6 additions & 7 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import * as fs from 'fs';
import * as webpack from 'webpack';
import rndstr from 'rndstr';
import * as chalk from 'chalk';
const { VueLoaderPlugin } = require('vue-loader');
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');

Expand All @@ -20,14 +20,15 @@ class WebpackOnBuildPlugin {
}

const isProduction = process.env.NODE_ENV == 'production';
const useHardSource = process.env.MISSKEY_USE_HARD_SOURCE;

const constants = require('./src/const.json');

const locales = require('./locales');
const meta = require('./package.json');
const codename = meta.codename;

const version = isProduction ? meta.version : meta.version + '-' + rndstr({ length: 8, chars: '0-9a-z' });

const postcss = {
loader: 'postcss-loader',
options: {
Expand Down Expand Up @@ -127,14 +128,13 @@ module.exports = {
}]
},
plugins: [
...(useHardSource ? [new HardSourceWebpackPlugin()] : []),
new ProgressBarPlugin({
format: chalk` {cyan.bold webpack} {bold [}:bar{bold ]} {green.bold :percent} :msg :elapseds`,
clear: false
}),
new webpack.DefinePlugin({
_COPYRIGHT_: JSON.stringify(constants.copyright),
_VERSION_: JSON.stringify(meta.version),
_VERSION_: JSON.stringify(version),
_CODENAME_: JSON.stringify(codename),
_LANGS_: JSON.stringify(Object.entries(locales).map(([k, v]: [string, any]) => [k, v && v.meta && v.meta.lang])),
_ENV_: JSON.stringify(process.env.NODE_ENV)
Expand All @@ -143,8 +143,7 @@ module.exports = {
'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development')
}),
new WebpackOnBuildPlugin((stats: any) => {
fs.writeFileSync('./built/meta.json', JSON.stringify({ version: meta.version }), 'utf-8');

fs.writeFileSync('./built/meta.json', JSON.stringify({ version }), 'utf-8');
fs.mkdirSync('./built/client/assets/locales', { recursive: true });

for (const [lang, locale] of Object.entries(locales))
Expand All @@ -154,7 +153,7 @@ module.exports = {
],
output: {
path: __dirname + '/built/client/assets',
filename: `[name].${meta.version}.js`,
filename: `[name].${version}.js`,
publicPath: `/assets/`
},
resolve: {
Expand Down

0 comments on commit be12a83

Please sign in to comment.