feat: themes foundation + editors load improvements
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
lokalise:
|
||||
api: https://api.lokalise.co/api
|
||||
project: 2994254859f751ea605a00.03473540
|
||||
key: 34b38266e48cb23b6e5dbd25eabe77ad8e6ec6f6
|
@@ -1,56 +0,0 @@
|
||||
const Promise = require('bluebird')
|
||||
const colors = require('colors/safe')
|
||||
const fs = Promise.promisifyAll(require('fs-extra'))
|
||||
const path = require('path')
|
||||
const request = require('request-promise')
|
||||
const yaml = require('js-yaml')
|
||||
const _ = require('lodash')
|
||||
|
||||
const config = yaml.safeLoad(fs.readFileSync(path.join(process.cwd(), 'dev/config/config.yml'), 'utf8'))
|
||||
|
||||
/**
|
||||
* Fetch Localization Resources from Lokalise
|
||||
*/
|
||||
const fetchLocalizationResources = async () => {
|
||||
console.info(colors.green('Fetching latest localization resources...'))
|
||||
let langs = await request({
|
||||
method: 'POST',
|
||||
uri: `${config.lokalise.api}/string/list`,
|
||||
form: {
|
||||
api_token: config.lokalise.key,
|
||||
id: config.lokalise.project
|
||||
},
|
||||
json: true
|
||||
})
|
||||
if (langs && langs.strings && _.isPlainObject(langs.strings)) {
|
||||
_.forIn(langs.strings, (langData, langKey) => {
|
||||
let lang = {}
|
||||
let langTotal = 0
|
||||
langData.forEach(item => {
|
||||
if (item.is_archived === '1' || _.includes(item.key, '::')) { return }
|
||||
let keyParts = item.key.split(':')
|
||||
let keyNamespace = (keyParts.length > 1) ? _.head(keyParts) : 'common'
|
||||
let keyString = _.last(keyParts)
|
||||
_.set(lang, `${keyNamespace}.${keyString}`, item.translation)
|
||||
langTotal++
|
||||
})
|
||||
_.forOwn(lang, (langObject, langNamespace) => {
|
||||
let langYaml = yaml.safeDump(langObject, {
|
||||
indent: 2,
|
||||
sortKeys: true,
|
||||
lineWidth: 2048
|
||||
})
|
||||
fs.outputFileSync(path.join(process.cwd(), `server/locales/${langKey}/${langNamespace}.yml`), langYaml, 'utf8')
|
||||
})
|
||||
console.info(colors.grey(`└─ ${langKey} - ${langTotal} keys written`))
|
||||
})
|
||||
} else {
|
||||
throw new Error('Failed to fetch language list from Lokalise API.')
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
fetchLocalizationResources()
|
||||
} catch (err) {
|
||||
console.error(colors.red(err))
|
||||
}
|
@@ -1,6 +1,8 @@
|
||||
const webpack = require('webpack')
|
||||
const path = require('path')
|
||||
const fs = require('fs-extra')
|
||||
const yargs = require('yargs').argv
|
||||
const _ = require('lodash')
|
||||
|
||||
const { VueLoaderPlugin } = require('vue-loader')
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
@@ -181,7 +183,8 @@ module.exports = {
|
||||
format: 'compact'
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': { NODE_ENV: '"development"' },
|
||||
'process.env.NODE_ENV': JSON.stringify('development'),
|
||||
'process.env.CURRENT_THEME': JSON.stringify(_.defaultTo(yargs.theme, 'default')),
|
||||
'__REACT_DEVTOOLS_GLOBAL_HOOK__': '({ isDisabled: true })'
|
||||
}),
|
||||
new WriteFilePlugin(),
|
||||
|
@@ -1,13 +1,14 @@
|
||||
const webpack = require('webpack')
|
||||
const path = require('path')
|
||||
const fs = require('fs-extra')
|
||||
const yargs = require('yargs').argv
|
||||
const _ = require('lodash')
|
||||
|
||||
const CleanWebpackPlugin = require('clean-webpack-plugin')
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const HtmlWebpackPugPlugin = require('html-webpack-pug-plugin')
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
const OfflinePlugin = require('offline-plugin')
|
||||
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
|
||||
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
|
||||
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin')
|
||||
@@ -208,24 +209,10 @@ module.exports = {
|
||||
cssProcessorOptions: { discardComments: { removeAll: true } },
|
||||
canPrint: true
|
||||
}),
|
||||
new OfflinePlugin({
|
||||
ServiceWorker: {
|
||||
minify: false
|
||||
},
|
||||
publicPath: '/',
|
||||
externals: ['/'],
|
||||
caches: {
|
||||
main: [
|
||||
'js/client.js'
|
||||
],
|
||||
additional: [
|
||||
':externals:'
|
||||
],
|
||||
optional: [
|
||||
'js/*.chunk.js'
|
||||
]
|
||||
},
|
||||
safeToUseOptionalCaches: true
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||
'process.env.CURRENT_THEME': JSON.stringify(_.defaultTo(yargs.theme, 'default')),
|
||||
'__REACT_DEVTOOLS_GLOBAL_HOOK__': '({ isDisabled: true })'
|
||||
})
|
||||
],
|
||||
optimization: {
|
||||
|
Reference in New Issue
Block a user