diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-03-15 05:26:24 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-03-15 05:26:24 +0900 |
| commit | 94b5729c8474a502e1cf390b539339b09c6a7a94 (patch) | |
| tree | d2fd9445d727d04c79d5efdc0fe7901b5a229692 /webpack | |
| parent | Update dependencies :rocket: (diff) | |
| download | sharkey-94b5729c8474a502e1cf390b539339b09c6a7a94.tar.gz sharkey-94b5729c8474a502e1cf390b539339b09c6a7a94.tar.bz2 sharkey-94b5729c8474a502e1cf390b539339b09c6a7a94.zip | |
:v:
Diffstat (limited to 'webpack')
| -rw-r--r-- | webpack/module/rules/collapse-spaces.ts | 19 | ||||
| -rw-r--r-- | webpack/plugins/consts.ts | 41 | ||||
| -rw-r--r-- | webpack/plugins/hoist.ts | 3 | ||||
| -rw-r--r-- | webpack/plugins/index.ts | 41 | ||||
| -rw-r--r-- | webpack/plugins/minify.ts | 3 | ||||
| -rw-r--r-- | webpack/webpack.config.ts | 177 |
6 files changed, 0 insertions, 284 deletions
diff --git a/webpack/module/rules/collapse-spaces.ts b/webpack/module/rules/collapse-spaces.ts deleted file mode 100644 index 734c735926..0000000000 --- a/webpack/module/rules/collapse-spaces.ts +++ /dev/null @@ -1,19 +0,0 @@ -import * as fs from 'fs'; -const minify = require('html-minifier').minify; - -export default () => ({ - enforce: 'pre', - test: /\.vue$/, - exclude: /node_modules/, - loader: 'string-replace-loader', - query: { - search: /^<template>([\s\S]+?)\r?\n<\/template>/, - replace: html => { - return minify(html, { - collapseWhitespace: true, - collapseInlineTagWhitespace: true, - keepClosingSlash: true - }); - } - } -}); diff --git a/webpack/plugins/consts.ts b/webpack/plugins/consts.ts deleted file mode 100644 index 6435893234..0000000000 --- a/webpack/plugins/consts.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Constant Replacer - */ - -import * as webpack from 'webpack'; - -const meta = require('../../package.json'); -const version = meta.version; - -const constants = require('../../src/const.json'); -import config from '../../src/conf'; -import { licenseHtml } from '../../src/common/build/license'; - -export default lang => { - const consts = { - _RECAPTCHA_SITEKEY_: config.recaptcha.site_key, - _SW_PUBLICKEY_: config.sw ? config.sw.public_key : null, - _THEME_COLOR_: constants.themeColor, - _COPYRIGHT_: constants.copyright, - _VERSION_: version, - _STATUS_URL_: config.status_url, - _STATS_URL_: config.stats_url, - _DOCS_URL_: config.docs_url, - _API_URL_: config.api_url, - _DEV_URL_: config.dev_url, - _CH_URL_: config.ch_url, - _LANG_: lang, - _HOST_: config.host, - _URL_: config.url, - _LICENSE_: licenseHtml, - _GOOGLE_MAPS_API_KEY_: config.google_maps_api_key - }; - - const _consts = {}; - - Object.keys(consts).forEach(key => { - _consts[key] = JSON.stringify(consts[key]); - }); - - return new webpack.DefinePlugin(_consts); -}; diff --git a/webpack/plugins/hoist.ts b/webpack/plugins/hoist.ts deleted file mode 100644 index f61133f8df..0000000000 --- a/webpack/plugins/hoist.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as webpack from 'webpack'; - -export default () => new webpack.optimize.ModuleConcatenationPlugin(); diff --git a/webpack/plugins/index.ts b/webpack/plugins/index.ts deleted file mode 100644 index 4023cd6cba..0000000000 --- a/webpack/plugins/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -import * as fs from 'fs'; -import * as webpack from 'webpack'; -const WebpackOnBuildPlugin = require('on-build-webpack'); -const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); -const ProgressBarPlugin = require('progress-bar-webpack-plugin'); -import chalk from 'chalk'; - -import consts from './consts'; -import hoist from './hoist'; -import minify from './minify'; - -const env = process.env.NODE_ENV; -const isProduction = env === 'production'; - -export default (version, lang) => { - const plugins = [ - new HardSourceWebpackPlugin(), - new ProgressBarPlugin({ - format: chalk` {cyan.bold yes we can} {bold [}:bar{bold ]} {green.bold :percent} {gray (:current/:total)} :elapseds`, - clear: false - }), - consts(lang), - new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: JSON.stringify(process.env.NODE_ENV) - } - }), - new WebpackOnBuildPlugin(stats => { - fs.writeFileSync('./version.json', JSON.stringify({ - version - }), 'utf-8'); - }) - ]; - - if (isProduction) { - plugins.push(hoist()); - plugins.push(minify()); - } - - return plugins; -}; diff --git a/webpack/plugins/minify.ts b/webpack/plugins/minify.ts deleted file mode 100644 index e46d4c5a10..0000000000 --- a/webpack/plugins/minify.ts +++ /dev/null @@ -1,3 +0,0 @@ -const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); - -export default () => new UglifyJsPlugin(); diff --git a/webpack/webpack.config.ts b/webpack/webpack.config.ts deleted file mode 100644 index c4ef4b90f5..0000000000 --- a/webpack/webpack.config.ts +++ /dev/null @@ -1,177 +0,0 @@ -/** - * webpack configuration - */ - -import * as fs from 'fs'; -import jsonImporter from 'node-sass-json-importer'; -const minify = require('html-minifier').minify; -import I18nReplacer from '../src/common/build/i18n'; -import { pattern as faPattern, replacement as faReplacement } from '../src/common/build/fa'; -const constants = require('../src/const.json'); - -import plugins from './plugins'; - -import langs from '../locales'; -const meta = require('../package.json'); -const version = meta.version; - -global['faReplacement'] = faReplacement; - -global['collapseSpacesReplacement'] = html => { - return minify(html, { - collapseWhitespace: true, - collapseInlineTagWhitespace: true, - keepClosingSlash: true - }).replace(/\t/g, ''); -}; - -global['base64replacement'] = (_, key) => { - return fs.readFileSync(__dirname + '/../src/web/' + key, 'base64'); -}; - -module.exports = Object.keys(langs).map(lang => { - // Chunk name - const name = lang; - - // Entries - const entry = { - desktop: './src/web/app/desktop/script.ts', - mobile: './src/web/app/mobile/script.ts', - //ch: './src/web/app/ch/script.ts', - //stats: './src/web/app/stats/script.ts', - //status: './src/web/app/status/script.ts', - dev: './src/web/app/dev/script.ts', - auth: './src/web/app/auth/script.ts', - sw: './src/web/app/sw.js' - }; - - const output = { - path: __dirname + '/../built/web/assets', - filename: `[name].${version}.${lang}.js` - }; - - const i18nReplacer = new I18nReplacer(lang); - global['i18nReplacement'] = i18nReplacer.replacement; - - return { - name, - entry, - module: { - rules: [{ - test: /\.vue$/, - exclude: /node_modules/, - use: [{ - loader: 'vue-loader', - options: { - cssSourceMap: false, - preserveWhitespace: false - } - }, { - loader: 'replace', - query: { - search: /%base64:(.+?)%/g.toString(), - replace: 'base64replacement' - } - }, { - loader: 'replace', - query: { - search: i18nReplacer.pattern.toString(), - replace: 'i18nReplacement' - } - }, { - loader: 'replace', - query: { - search: faPattern.toString(), - replace: 'faReplacement' - } - }, { - loader: 'replace', - query: { - search: /^<template>([\s\S]+?)\r?\n<\/template>/.toString(), - replace: 'collapseSpacesReplacement' - } - }] - }, { - test: /\.styl$/, - exclude: /node_modules/, - use: [{ - loader: 'style-loader' - }, { - loader: 'css-loader', - options: { - minimize: true - } - }, { - loader: 'stylus-loader' - } - ] - }, { - test: /\.scss$/, - exclude: /node_modules/, - use: [{ - loader: 'style-loader' - }, { - loader: 'css-loader', - options: { - minimize: true - } - }, { - loader: 'sass-loader', - options: { - importer: jsonImporter, - } - }] - }, { - test: /\.css$/, - use: [{ - loader: 'style-loader' - }, { - loader: 'css-loader', - options: { - minimize: true - } - }] - }, { - test: /\.(eot|woff|woff2|svg|ttf)([\?]?.*)$/, - loader: 'url-loader' - }, { - test: /\.ts$/, - exclude: /node_modules/, - use: [{ - loader: 'ts-loader', - options: { - happyPackMode: true, - configFile: __dirname + '/../src/web/app/tsconfig.json', - appendTsSuffixTo: [/\.vue$/] - } - }, { - loader: 'replace', - query: { - search: i18nReplacer.pattern.toString(), - replace: 'i18nReplacement' - } - }, { - loader: 'replace', - query: { - search: faPattern.toString(), - replace: 'faReplacement' - } - }] - }] - }, - plugins: plugins(version, lang), - output, - resolve: { - extensions: [ - '.js', '.ts', '.json' - ], - alias: { - 'const.styl': __dirname + '/../src/web/const.styl' - } - }, - resolveLoader: { - modules: ['node_modules', './webpack/loaders'] - }, - cache: true - }; -}); |