This commit is contained in:
William Durand 2018-06-27 17:51:33 +02:00 коммит произвёл GitHub
Родитель f7ce07f42f
Коммит 24936148ad
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 106 добавлений и 86 удалений

19
.prettierignore Normal file
Просмотреть файл

@ -0,0 +1,19 @@
# exclude everything by default
*.*
# exclude these files
Dockerfile
# exclude these directories
/assets/
/bin/
/config/
/dist/
/docker/
/flow/
/locale/
/node_modules/
/src/core/fonts/
/src/disco/video/
/src/locale/
/tests/ui/
# white-list files we want to process
!*.js

Просмотреть файл

@ -5,15 +5,8 @@ module.exports = {
'<rootDir>/src/core/server/webpack-isomorphic-tools-config.js',
'<rootDir>/src/locale/',
],
moduleDirectories: [
'src',
'node_modules',
],
moduleFileExtensions: [
'js',
'json',
'jsx',
],
moduleDirectories: ['src', 'node_modules'],
moduleFileExtensions: ['js', 'json', 'jsx'],
moduleNameMapper: {
// Prevent un-transpiled react-photoswipe code being required.
'^photoswipe$': '<rootDir>/node_modules/photoswipe',
@ -29,10 +22,7 @@ module.exports = {
'<rootDir>/node_modules/',
'<rootDir>/(assets|bin|config|coverage|dist|docs|flow|locale|src)/',
],
testMatch: [
'**/[Tt]est(*).js?(x)',
'**/__tests__/**/*.js?(x)',
],
testMatch: ['**/[Tt]est(*).js?(x)', '**/__tests__/**/*.js?(x)'],
// This will initialize the jsdom document with a URL which is necessary
// for History push state to work.
// See https://github.com/ReactTraining/react-router/issues/5030
@ -43,9 +33,7 @@ module.exports = {
// Tests can assert on the filenname.
'^.+\\.(jpg|jpeg|gif|png)$': '<rootDir>/tests/fileTransformer',
},
transformIgnorePatterns: [
'<rootDir>/node_modules/',
],
transformIgnorePatterns: ['<rootDir>/node_modules/'],
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',

Просмотреть файл

@ -24,7 +24,7 @@
"flow:dev": "flow stop; flow start; chokidar .flowconfig flow/ src/ tests/ -i flow/logs/flow.log -c 'flow status' --initial",
"stylelint": "stylelint --syntax scss **/*.scss",
"lint": "npm run eslint && npm run stylelint",
"prettier": "prettier --write '{src,tests}/**/*.js'",
"prettier": "prettier --write '**'",
"prettier-ci": "npm run prettier -- --list-different || (echo '\n\nThis failure means you did not run `yarn prettier` before committing\n\n' && exit 1)",
"start": "npm run version-check && better-npm-run node bin/server.js",
"start-func-test-server": "better-npm-run node bin/start-func-test-server.js",

Просмотреть файл

@ -17,10 +17,12 @@ const urlLoaderOptions = {
const postCssPlugins = [];
if (config.get('enablePostCssLoader')) {
postCssPlugins.push(autoprefixer({
browsers: ['last 2 versions'],
grid: false,
}));
postCssPlugins.push(
autoprefixer({
browsers: ['last 2 versions'],
grid: false,
}),
);
}
export function getRules({ babelQuery, bundleStylesWithJs = false } = {}) {
@ -122,7 +124,8 @@ export function getRules({ babelQuery, bundleStylesWithJs = false } = {}) {
{
test: /\.svg$/,
use: [{ loader: 'svg-url-loader', options: urlLoaderOptions }],
}, {
},
{
test: /\.(jpg|png|gif|webm|mp4|otf|woff|woff2)$/,
use: [{ loader: 'url-loader', options: urlLoaderOptions }],
},
@ -144,13 +147,19 @@ export function getPlugins({ excludeOtherAppLocales = true } = {}) {
// This replaces the config with a new module that has sensitive,
// server-only keys removed.
new webpack.NormalModuleReplacementPlugin(
/config$/, 'core/client/config.js'),
/config$/,
'core/client/config.js',
),
// This replaces the logger with a more lightweight logger for the client.
new webpack.NormalModuleReplacementPlugin(
/core\/logger$/, 'core/client/logger.js'),
/core\/logger$/,
'core/client/logger.js',
),
// This swaps the server side window object with a standard browser window.
new webpack.NormalModuleReplacementPlugin(
/core\/window/, 'core/browserWindow.js'),
/core\/window/,
'core/browserWindow.js',
),
new CircularDependencyPlugin({
exclude: /node_modules/,
failOnError: true,
@ -162,7 +171,7 @@ export function getPlugins({ excludeOtherAppLocales = true } = {}) {
// This allow us to exclude locales for other apps being built.
new webpack.ContextReplacementPlugin(
/locale$/,
new RegExp(`^\\.\\/.*?\\/${appName}\\.js$`)
new RegExp(`^\\.\\/.*?\\/${appName}\\.js$`),
),
);
}

Просмотреть файл

@ -9,30 +9,37 @@ import WebpackIsomorphicToolsPlugin from 'webpack-isomorphic-tools/plugin';
import { getPlugins, getRules } from './webpack-common';
import webpackConfig from './webpack.prod.config.babel';
import webpackIsomorphicToolsConfig
from './src/core/server/webpack-isomorphic-tools-config';
import webpackIsomorphicToolsConfig from './src/core/server/webpack-isomorphic-tools-config';
const localDevelopment = config.util.getEnv('NODE_ENV') === 'development';
const webpackIsomorphicToolsPlugin =
new WebpackIsomorphicToolsPlugin(webpackIsomorphicToolsConfig);
const webpackIsomorphicToolsPlugin = new WebpackIsomorphicToolsPlugin(
webpackIsomorphicToolsConfig,
);
const babelrc = fs.readFileSync('./.babelrc');
const babelrcObject = JSON.parse(babelrc);
const babelPlugins = babelrcObject.plugins || [];
const babelDevPlugins = [['react-transform', {
transforms: [{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module'],
}],
}]];
const babelDevPlugins = [
[
'react-transform',
{
transforms: [
{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module'],
},
],
},
],
];
const BABEL_QUERY = Object.assign({}, babelrcObject, {
plugins: localDevelopment ?
babelPlugins.concat(babelDevPlugins) : babelPlugins,
plugins: localDevelopment
? babelPlugins.concat(babelDevPlugins)
: babelPlugins,
});
const webpackHost = config.get('webpackServerHost');
@ -46,10 +53,7 @@ const appsBuildList = appName ? [appName] : config.get('validAppNames');
const entryPoints = {};
for (const app of appsBuildList) {
entryPoints[app] = [
hmr,
`${app}/client`,
];
entryPoints[app] = [hmr, `${app}/client`];
}
export default Object.assign({}, webpackConfig, {
@ -75,11 +79,14 @@ export default Object.assign({}, webpackConfig, {
// [Invariant](https://github.com/zertosh/invariant) which
// hides error messages in the production build.
new webpack.NormalModuleReplacementPlugin(
/^react$/, 'react/umd/react.development.js'),
/^react$/,
'react/umd/react.development.js',
),
new webpack.NormalModuleReplacementPlugin(
/^react-dom$/, 'react-dom/umd/react-dom.development.js'),
new webpack.NormalModuleReplacementPlugin(
/^redux$/, 'redux/dist/redux.js'),
/^react-dom$/,
'react-dom/umd/react-dom.development.js',
),
new webpack.NormalModuleReplacementPlugin(/^redux$/, 'redux/dist/redux.js'),
new webpack.HotModuleReplacementPlugin(),
new webpack.IgnorePlugin(/webpack-stats\.json$/),
webpackIsomorphicToolsPlugin.development(),

Просмотреть файл

@ -8,18 +8,15 @@ import webpack from 'webpack';
import { getRules } from './webpack-common';
import webpackConfig from './webpack.prod.config.babel';
const appName = config.get('appName');
if (!appName) {
console.log(
chalk.red('Please specify the appName with NODE_APP_INSTANCE'));
console.log(chalk.red('Please specify the appName with NODE_APP_INSTANCE'));
process.exit(1);
}
if (process.env.NODE_ENV !== 'production') {
console.log(
chalk.red('This should be run with NODE_ENV="production"'));
console.log(chalk.red('This should be run with NODE_ENV="production"'));
process.exit(1);
}
@ -28,38 +25,42 @@ const babelrcObject = JSON.parse(babelrc);
const babelPlugins = babelrcObject.plugins || [];
// Create UTC creation date in the correct format.
const potCreationDate = new Date().toISOString()
const potCreationDate = new Date()
.toISOString()
.replace('T', ' ')
.replace(/:\d{2}.\d{3}Z/, '+0000');
const babelL10nPlugins = [
['babel-gettext-extractor', {
headers: {
'Project-Id-Version': appName,
'Report-Msgid-Bugs-To': 'EMAIL@ADDRESS',
'POT-Creation-Date': potCreationDate,
'PO-Revision-Date': 'YEAR-MO-DA HO:MI+ZONE',
'Last-Translator': 'FULL NAME <EMAIL@ADDRESS>',
'Language-Team': 'LANGUAGE <LL@li.org>',
'MIME-Version': '1.0',
'Content-Type': 'text/plain; charset=utf-8',
'Content-Transfer-Encoding': '8bit',
'plural-forms': 'nplurals=2; plural=(n!=1);',
[
'babel-gettext-extractor',
{
headers: {
'Project-Id-Version': appName,
'Report-Msgid-Bugs-To': 'EMAIL@ADDRESS',
'POT-Creation-Date': potCreationDate,
'PO-Revision-Date': 'YEAR-MO-DA HO:MI+ZONE',
'Last-Translator': 'FULL NAME <EMAIL@ADDRESS>',
'Language-Team': 'LANGUAGE <LL@li.org>',
'MIME-Version': '1.0',
'Content-Type': 'text/plain; charset=utf-8',
'Content-Transfer-Encoding': '8bit',
'plural-forms': 'nplurals=2; plural=(n!=1);',
},
functionNames: {
gettext: ['msgid'],
dgettext: ['domain', 'msgid'],
ngettext: ['msgid', 'msgid_plural', 'count'],
dngettext: ['domain', 'msgid', 'msgid_plural', 'count'],
pgettext: ['msgctxt', 'msgid'],
dpgettext: ['domain', 'msgctxt', 'msgid'],
npgettext: ['msgctxt', 'msgid', 'msgid_plural', 'count'],
dnpgettext: ['domain', 'msgctxt', 'msgid', 'msgid_plural', 'count'],
},
fileName: `locale/templates/LC_MESSAGES/${appName}.pot`,
baseDirectory: process.cwd(),
stripTemplateLiteralIndent: true,
},
functionNames: {
gettext: ['msgid'],
dgettext: ['domain', 'msgid'],
ngettext: ['msgid', 'msgid_plural', 'count'],
dngettext: ['domain', 'msgid', 'msgid_plural', 'count'],
pgettext: ['msgctxt', 'msgid'],
dpgettext: ['domain', 'msgctxt', 'msgid'],
npgettext: ['msgctxt', 'msgid', 'msgid_plural', 'count'],
dnpgettext: ['domain', 'msgctxt', 'msgid', 'msgid_plural', 'count'],
},
fileName: `locale/templates/LC_MESSAGES/${appName}.pot`,
baseDirectory: process.cwd(),
stripTemplateLiteralIndent: true,
}],
],
];
const BABEL_QUERY = Object.assign({}, babelrcObject, {

Просмотреть файл

@ -9,8 +9,7 @@ import WebpackIsomorphicToolsPlugin from 'webpack-isomorphic-tools/plugin';
import SriDataPlugin from './src/core/server/sriDataPlugin';
import { getPlugins, getRules } from './webpack-common';
import webpackIsomorphicToolsConfig
from './src/core/server/webpack-isomorphic-tools-config';
import webpackIsomorphicToolsConfig from './src/core/server/webpack-isomorphic-tools-config';
const appName = config.get('appName');
const appsBuildList = appName ? [appName] : config.get('validAppNames');
@ -77,10 +76,7 @@ export default {
'normalize.css': 'normalize.css/normalize.css',
tests: path.resolve('./tests'),
},
modules: [
path.resolve('./src'),
'node_modules',
],
modules: [path.resolve('./src'), 'node_modules'],
extensions: ['.js', '.jsx'],
},
};