summaryrefslogtreecommitdiff
path: root/webpack
diff options
context:
space:
mode:
Diffstat (limited to 'webpack')
-rw-r--r--webpack/module/rules/base64.ts19
-rw-r--r--webpack/module/rules/index.ts6
-rw-r--r--webpack/module/rules/typescript.ts8
-rw-r--r--webpack/plugins/index.ts8
-rw-r--r--webpack/plugins/minify.ts4
5 files changed, 37 insertions, 8 deletions
diff --git a/webpack/module/rules/base64.ts b/webpack/module/rules/base64.ts
new file mode 100644
index 0000000000..529816bd20
--- /dev/null
+++ b/webpack/module/rules/base64.ts
@@ -0,0 +1,19 @@
+/**
+ * Replace base64 symbols
+ */
+
+import * as fs from 'fs';
+const StringReplacePlugin = require('string-replace-webpack-plugin');
+
+export default () => ({
+ enforce: 'pre',
+ test: /\.(tag|js)$/,
+ exclude: /node_modules/,
+ loader: StringReplacePlugin.replace({
+ replacements: [{
+ pattern: /%base64:(.+?)%/g, replacement: (_, key) => {
+ return fs.readFileSync(__dirname + '/../../../src/web/' + key, 'base64');
+ }
+ }]
+ })
+});
diff --git a/webpack/module/rules/index.ts b/webpack/module/rules/index.ts
index 2308f4e535..9c1262b3d6 100644
--- a/webpack/module/rules/index.ts
+++ b/webpack/module/rules/index.ts
@@ -1,11 +1,15 @@
import i18n from './i18n';
+import base64 from './base64';
import themeColor from './theme-color';
import tag from './tag';
import stylus from './stylus';
+import typescript from './typescript';
export default (lang, locale) => [
i18n(lang, locale),
+ base64(),
themeColor(),
tag(),
- stylus()
+ stylus(),
+ typescript()
];
diff --git a/webpack/module/rules/typescript.ts b/webpack/module/rules/typescript.ts
new file mode 100644
index 0000000000..eb2b279a55
--- /dev/null
+++ b/webpack/module/rules/typescript.ts
@@ -0,0 +1,8 @@
+/**
+ * TypeScript
+ */
+
+export default () => ({
+ test: /\.ts$/,
+ use: 'awesome-typescript-loader'
+});
diff --git a/webpack/plugins/index.ts b/webpack/plugins/index.ts
index 99b16c2b05..d5191f1555 100644
--- a/webpack/plugins/index.ts
+++ b/webpack/plugins/index.ts
@@ -2,13 +2,11 @@ const StringReplacePlugin = require('string-replace-webpack-plugin');
import constant from './const';
import hoist from './hoist';
-//import minify from './minify';
+import minify from './minify';
import banner from './banner';
-/*
const env = process.env.NODE_ENV;
const isProduction = env === 'production';
-*/
export default version => {
const plugins = [
@@ -16,11 +14,11 @@ export default version => {
new StringReplacePlugin(),
hoist()
];
-/*
+
if (isProduction) {
plugins.push(minify());
}
-*/
+
plugins.push(banner(version));
return plugins;
diff --git a/webpack/plugins/minify.ts b/webpack/plugins/minify.ts
index ec4c9b3405..e46d4c5a10 100644
--- a/webpack/plugins/minify.ts
+++ b/webpack/plugins/minify.ts
@@ -1,3 +1,3 @@
-const UglifyEsPlugin = require('uglify-es-webpack-plugin');
+const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
-export default () => new UglifyEsPlugin();
+export default () => new UglifyJsPlugin();