summaryrefslogtreecommitdiff
path: root/webpack.config.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-18 00:02:41 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-18 00:02:53 +0900
commit5ad77e8a3a7d3771559b02ea5c3e445ff2983533 (patch)
treed6fbaa72a612baadee18e24c9ebc7e6a1fa3eb54 /webpack.config.ts
parent7.7.3 (diff)
downloadmisskey-5ad77e8a3a7d3771559b02ea5c3e445ff2983533.tar.gz
misskey-5ad77e8a3a7d3771559b02ea5c3e445ff2983533.tar.bz2
misskey-5ad77e8a3a7d3771559b02ea5c3e445ff2983533.zip
nanka iroiro
Diffstat (limited to 'webpack.config.ts')
-rw-r--r--webpack.config.ts126
1 files changed, 66 insertions, 60 deletions
diff --git a/webpack.config.ts b/webpack.config.ts
index 90e23d104a..65aeda5ea4 100644
--- a/webpack.config.ts
+++ b/webpack.config.ts
@@ -4,73 +4,79 @@
import * as webpack from 'webpack';
const StringReplacePlugin = require('string-replace-webpack-plugin');
+import getVersion from './src/version';
const constants = require('./src/const.json');
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
+module.exports = new Promise(async resolve => {
+ const version = await getVersion.then();
+
+ 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' }
+ ]
}
- },
- {
- 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'
- }
-};
+ ]
+ },
+ plugins: [
+ new webpack.DefinePlugin({
+ VERSION: JSON.stringify(version),
+ CONFIG: {
+ themeColor: JSON.stringify(constants.themeColor)
+ }
+ }),
+ new StringReplacePlugin()
+ ],
+ output: {
+ filename: `[name]/script.${version}.js`
+ }
+ };
-if (isProduction) {
- //pack.plugins.push(new webpack.optimize.UglifyJsPlugin());
-}
+ if (isProduction) {
+ //pack.plugins.push(new webpack.optimize.UglifyJsPlugin());
+ }
-module.exports = pack;
+ resolve(pack);
+});