mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Merge b7e971f2d1
into a50c8e951f
This commit is contained in:
commit
e3a6127e3b
7 changed files with 48 additions and 37 deletions
|
@ -83,3 +83,4 @@ AUTHORS.md
|
||||||
|
|
||||||
# Process a few selected JS files
|
# Process a few selected JS files
|
||||||
!lint-staged.config.js
|
!lint-staged.config.js
|
||||||
|
!/config/**/*.js
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const currentTranslations = require(path.join(__dirname, "../app/javascript/mastodon/locales/en.json"));
|
const currentTranslations = require(
|
||||||
|
path.join(__dirname, '../app/javascript/mastodon/locales/en.json'),
|
||||||
|
);
|
||||||
|
|
||||||
exports.format = (msgs) => {
|
exports.format = (msgs) => {
|
||||||
const results = {};
|
const results = {};
|
||||||
|
|
|
@ -7,7 +7,9 @@ const { env } = require('process');
|
||||||
const { load } = require('js-yaml');
|
const { load } = require('js-yaml');
|
||||||
|
|
||||||
const configPath = resolve('config', 'webpacker.yml');
|
const configPath = resolve('config', 'webpacker.yml');
|
||||||
const settings = load(readFileSync(configPath), 'utf8')[env.RAILS_ENV || env.NODE_ENV];
|
const settings = load(readFileSync(configPath), 'utf8')[
|
||||||
|
env.RAILS_ENV || env.NODE_ENV
|
||||||
|
];
|
||||||
|
|
||||||
const themePath = resolve('config', 'themes.yml');
|
const themePath = resolve('config', 'themes.yml');
|
||||||
const themes = load(readFileSync(themePath), 'utf8');
|
const themes = load(readFileSync(themePath), 'utf8');
|
||||||
|
|
|
@ -57,6 +57,6 @@ module.exports = merge(sharedConfig, {
|
||||||
settings.dev_server.watch_options,
|
settings.dev_server.watch_options,
|
||||||
watchOptions,
|
watchOptions,
|
||||||
),
|
),
|
||||||
writeToDisk: filePath => /ocr/.test(filePath),
|
writeToDisk: (filePath) => /ocr/.test(filePath),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,24 +42,27 @@ module.exports = merge(sharedConfig, {
|
||||||
cache: true,
|
cache: true,
|
||||||
test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/,
|
test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/,
|
||||||
}),
|
}),
|
||||||
new BundleAnalyzerPlugin({ // generates report.html
|
new BundleAnalyzerPlugin({
|
||||||
|
// generates report.html
|
||||||
analyzerMode: 'static',
|
analyzerMode: 'static',
|
||||||
openAnalyzer: false,
|
openAnalyzer: false,
|
||||||
logLevel: 'silent', // do not bother Webpacker, who runs with --json and parses stdout
|
logLevel: 'silent', // do not bother Webpacker, who runs with --json and parses stdout
|
||||||
}),
|
}),
|
||||||
new InjectManifest({
|
new InjectManifest({
|
||||||
additionalManifestEntries: ['1f602.svg', 'sheet_13.png'].map((filename) => {
|
additionalManifestEntries: ['1f602.svg', 'sheet_13.png'].map(
|
||||||
const path = resolve(root, 'public', 'emoji', filename);
|
(filename) => {
|
||||||
const body = readFileSync(path);
|
const path = resolve(root, 'public', 'emoji', filename);
|
||||||
const md5 = createHash('md5');
|
const body = readFileSync(path);
|
||||||
|
const md5 = createHash('md5');
|
||||||
|
|
||||||
md5.update(body);
|
md5.update(body);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
revision: md5.digest('hex'),
|
revision: md5.digest('hex'),
|
||||||
url: `/emoji/${filename}`,
|
url: `/emoji/${filename}`,
|
||||||
};
|
};
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
exclude: [
|
exclude: [
|
||||||
/(?:base|extra)_polyfills-.*\.js$/,
|
/(?:base|extra)_polyfills-.*\.js$/,
|
||||||
/locale_.*\.js$/,
|
/locale_.*\.js$/,
|
||||||
|
@ -68,7 +71,14 @@ module.exports = merge(sharedConfig, {
|
||||||
include: [/\.js$/, /\.css$/],
|
include: [/\.js$/, /\.css$/],
|
||||||
maximumFileSizeToCacheInBytes: 2 * 1_024 * 1_024, // 2 MiB
|
maximumFileSizeToCacheInBytes: 2 * 1_024 * 1_024, // 2 MiB
|
||||||
swDest: resolve(root, 'public', 'packs', 'sw.js'),
|
swDest: resolve(root, 'public', 'packs', 'sw.js'),
|
||||||
swSrc: resolve(root, 'app', 'javascript', 'mastodon', 'service_worker', 'entry.js'),
|
swSrc: resolve(
|
||||||
|
root,
|
||||||
|
'app',
|
||||||
|
'javascript',
|
||||||
|
'mastodon',
|
||||||
|
'service_worker',
|
||||||
|
'entry.js',
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,18 +3,18 @@ const { join, resolve } = require('path');
|
||||||
const { env, settings } = require('../configuration');
|
const { env, settings } = require('../configuration');
|
||||||
|
|
||||||
// Those modules contain modern ES code that need to be transpiled for Webpack to process it
|
// Those modules contain modern ES code that need to be transpiled for Webpack to process it
|
||||||
const nodeModulesToProcess = [
|
const nodeModulesToProcess = ['@reduxjs', 'fuzzysort'];
|
||||||
'@reduxjs', 'fuzzysort'
|
|
||||||
];
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
test: /\.(js|jsx|mjs|ts|tsx)$/,
|
test: /\.(js|jsx|mjs|ts|tsx)$/,
|
||||||
include: [
|
include: [
|
||||||
settings.source_path,
|
settings.source_path,
|
||||||
...settings.resolved_paths,
|
...settings.resolved_paths,
|
||||||
...nodeModulesToProcess.map(p => resolve(`node_modules/${p}`)),
|
...nodeModulesToProcess.map((p) => resolve(`node_modules/${p}`)),
|
||||||
].map(p => resolve(p)),
|
].map((p) => resolve(p)),
|
||||||
exclude: new RegExp('node_modules\\/(?!(' + nodeModulesToProcess.join('|')+')\\/).*'),
|
exclude: new RegExp(
|
||||||
|
'node_modules\\/(?!(' + nodeModulesToProcess.join('|') + ')\\/).*',
|
||||||
|
),
|
||||||
use: [
|
use: [
|
||||||
{
|
{
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
|
|
|
@ -21,7 +21,8 @@ module.exports = {
|
||||||
packPaths.reduce((map, entry) => {
|
packPaths.reduce((map, entry) => {
|
||||||
const localMap = map;
|
const localMap = map;
|
||||||
const namespace = relative(join(entryPath), dirname(entry));
|
const namespace = relative(join(entryPath), dirname(entry));
|
||||||
localMap[join(namespace, basename(entry, extname(entry)))] = resolve(entry);
|
localMap[join(namespace, basename(entry, extname(entry)))] =
|
||||||
|
resolve(entry);
|
||||||
return localMap;
|
return localMap;
|
||||||
}, {}),
|
}, {}),
|
||||||
Object.keys(themes).reduce((themePaths, name) => {
|
Object.keys(themes).reduce((themePaths, name) => {
|
||||||
|
@ -61,19 +62,17 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
module: {
|
module: {
|
||||||
rules: Object.keys(rules).map(key => rules[key]),
|
rules: Object.keys(rules).map((key) => rules[key]),
|
||||||
strictExportPresence: true,
|
strictExportPresence: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))),
|
new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))),
|
||||||
new webpack.NormalModuleReplacementPlugin(
|
new webpack.NormalModuleReplacementPlugin(/^history\//, (resource) => {
|
||||||
/^history\//, (resource) => {
|
// temporary fix for https://github.com/ReactTraining/react-router/issues/5576
|
||||||
// temporary fix for https://github.com/ReactTraining/react-router/issues/5576
|
// to reduce bundle size
|
||||||
// to reduce bundle size
|
resource.request = resource.request.replace(/^history/, 'history/es');
|
||||||
resource.request = resource.request.replace(/^history/, 'history/es');
|
}),
|
||||||
},
|
|
||||||
),
|
|
||||||
new MiniCssExtractPlugin({
|
new MiniCssExtractPlugin({
|
||||||
filename: 'css/[name]-[contenthash:8].css',
|
filename: 'css/[name]-[contenthash:8].css',
|
||||||
chunkFilename: 'css/[name]-[contenthash:8].chunk.css',
|
chunkFilename: 'css/[name]-[contenthash:8].chunk.css',
|
||||||
|
@ -87,18 +86,15 @@ module.exports = {
|
||||||
}),
|
}),
|
||||||
new CircularDependencyPlugin({
|
new CircularDependencyPlugin({
|
||||||
failOnError: true,
|
failOnError: true,
|
||||||
})
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: settings.extensions,
|
extensions: settings.extensions,
|
||||||
modules: [
|
modules: [resolve(settings.source_path), 'node_modules'],
|
||||||
resolve(settings.source_path),
|
|
||||||
'node_modules',
|
|
||||||
],
|
|
||||||
alias: {
|
alias: {
|
||||||
"@": resolve(settings.source_path),
|
'@': resolve(settings.source_path),
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
resolveLoader: {
|
resolveLoader: {
|
||||||
|
|
Loading…
Reference in a new issue