improve interpackage config sharing
This commit is contained in:
parent
8a0ffa7b9b
commit
19f484eeda
@ -10,23 +10,6 @@ module.exports = {
|
|||||||
['babel-plugin-transform-builtin-extend', {
|
['babel-plugin-transform-builtin-extend', {
|
||||||
globals: ['Error']
|
globals: ['Error']
|
||||||
}],
|
}],
|
||||||
['module-resolver', {
|
|
||||||
root: [
|
|
||||||
'./src/components'
|
|
||||||
],
|
|
||||||
alias: {
|
|
||||||
Actions: './src/actions/',
|
|
||||||
Backends: './src/backends/',
|
|
||||||
Constants: './src/constants/',
|
|
||||||
Formats: './src/formats/',
|
|
||||||
Integrations: './src/integrations/',
|
|
||||||
Lib: './src/lib/',
|
|
||||||
Reducers: './src/reducers/',
|
|
||||||
Redux: './src/redux/',
|
|
||||||
Routing: './src/routing/',
|
|
||||||
ValueObjects: './src/valueObjects/',
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
'transform-export-extensions',
|
'transform-export-extensions',
|
||||||
'@babel/plugin-proposal-class-properties',
|
'@babel/plugin-proposal-class-properties',
|
||||||
'@babel/plugin-proposal-object-rest-spread',
|
'@babel/plugin-proposal-object-rest-spread',
|
||||||
|
@ -1 +1,3 @@
|
|||||||
module.exports = require('../../webpack.config.js');
|
const { getConfig } = require('../../scripts/webpack.js');
|
||||||
|
|
||||||
|
module.exports = getConfig();
|
||||||
|
@ -1 +1,3 @@
|
|||||||
module.exports = require('../../webpack.config.js');
|
const { getConfig } = require('../../scripts/webpack.js');
|
||||||
|
|
||||||
|
module.exports = getConfig();
|
||||||
|
@ -1 +1,3 @@
|
|||||||
module.exports = require('../../webpack.config.js');
|
const { getConfig } = require('../../scripts/webpack.js');
|
||||||
|
|
||||||
|
module.exports = getConfig();
|
||||||
|
@ -1 +1,3 @@
|
|||||||
module.exports = require('../../webpack.config.js');
|
const { getConfig } = require('../../scripts/webpack.js');
|
||||||
|
|
||||||
|
module.exports = getConfig();
|
||||||
|
23
packages/netlify-cms-core/babel.config.js
Normal file
23
packages/netlify-cms-core/babel.config.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
const babelConfig = require('../../babel.config.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
...babelConfig,
|
||||||
|
plugins: [
|
||||||
|
...babelConfig.plugins,
|
||||||
|
['module-resolver', {
|
||||||
|
root: './src/components',
|
||||||
|
alias: {
|
||||||
|
src: './src',
|
||||||
|
Actions: './src/actions/',
|
||||||
|
Constants: './src/constants/',
|
||||||
|
Formats: './src/formats/',
|
||||||
|
Integrations: './src/integrations/',
|
||||||
|
Lib: './src/lib/',
|
||||||
|
Reducers: './src/reducers/',
|
||||||
|
Redux: './src/redux/',
|
||||||
|
Routing: './src/routing/',
|
||||||
|
ValueObjects: './src/valueObjects/',
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
};
|
@ -1,5 +1,5 @@
|
|||||||
import { actions as notifActions } from 'redux-notifications';
|
import { actions as notifActions } from 'redux-notifications';
|
||||||
import { currentBackend } from 'Backends/backend';
|
import { currentBackend } from 'src/backend';
|
||||||
|
|
||||||
const { notifSend } = notifActions;
|
const { notifSend } = notifActions;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import uuid from 'uuid/v4';
|
|||||||
import { actions as notifActions } from 'redux-notifications';
|
import { actions as notifActions } from 'redux-notifications';
|
||||||
import { BEGIN, COMMIT, REVERT } from 'redux-optimist';
|
import { BEGIN, COMMIT, REVERT } from 'redux-optimist';
|
||||||
import { serializeValues } from 'Lib/serializeEntryValues';
|
import { serializeValues } from 'Lib/serializeEntryValues';
|
||||||
import { currentBackend } from 'Backends/backend';
|
import { currentBackend } from 'src/backend';
|
||||||
import { getAsset } from 'Reducers';
|
import { getAsset } from 'Reducers';
|
||||||
import { selectFields } from 'Reducers/collections';
|
import { selectFields } from 'Reducers/collections';
|
||||||
import { status, EDITORIAL_WORKFLOW } from 'Constants/publishModes';
|
import { status, EDITORIAL_WORKFLOW } from 'Constants/publishModes';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { fromJS, List, Set } from 'immutable';
|
import { fromJS, List, Set } from 'immutable';
|
||||||
import { actions as notifActions } from 'redux-notifications';
|
import { actions as notifActions } from 'redux-notifications';
|
||||||
import { serializeValues } from 'Lib/serializeEntryValues';
|
import { serializeValues } from 'Lib/serializeEntryValues';
|
||||||
import { currentBackend } from 'Backends/backend';
|
import { currentBackend } from 'src/backend';
|
||||||
import { getIntegrationProvider } from 'Integrations';
|
import { getIntegrationProvider } from 'Integrations';
|
||||||
import { getAsset, selectIntegration } from 'Reducers';
|
import { getAsset, selectIntegration } from 'Reducers';
|
||||||
import { selectFields } from 'Reducers/collections';
|
import { selectFields } from 'Reducers/collections';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { actions as notifActions } from 'redux-notifications';
|
import { actions as notifActions } from 'redux-notifications';
|
||||||
import { currentBackend } from 'Backends/backend';
|
import { currentBackend } from 'src/backend';
|
||||||
import { createAssetProxy } from 'ValueObjects/AssetProxy';
|
import { createAssetProxy } from 'ValueObjects/AssetProxy';
|
||||||
import { getAsset, selectIntegration } from 'Reducers';
|
import { getAsset, selectIntegration } from 'Reducers';
|
||||||
import { getIntegrationProvider } from 'Integrations';
|
import { getIntegrationProvider } from 'Integrations';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import fuzzy from 'fuzzy';
|
import fuzzy from 'fuzzy';
|
||||||
import { currentBackend } from 'Backends/backend';
|
import { currentBackend } from 'src/backend';
|
||||||
import { getIntegrationProvider } from 'Integrations';
|
import { getIntegrationProvider } from 'Integrations';
|
||||||
import { selectIntegration, selectEntries } from 'Reducers';
|
import { selectIntegration, selectEntries } from 'Reducers';
|
||||||
import { selectInferedField } from 'Reducers/collections';
|
import { selectInferedField } from 'Reducers/collections';
|
||||||
|
@ -9,7 +9,7 @@ import { Notifs } from 'redux-notifications';
|
|||||||
import TopBarProgress from 'react-topbar-progress-indicator';
|
import TopBarProgress from 'react-topbar-progress-indicator';
|
||||||
import { loadConfig as actionLoadConfig } from 'Actions/config';
|
import { loadConfig as actionLoadConfig } from 'Actions/config';
|
||||||
import { loginUser as actionLoginUser, logoutUser as actionLogoutUser } from 'Actions/auth';
|
import { loginUser as actionLoginUser, logoutUser as actionLogoutUser } from 'Actions/auth';
|
||||||
import { currentBackend } from 'Backends/backend';
|
import { currentBackend } from 'src/backend';
|
||||||
import { showCollection, createNewEntry } from 'Actions/collections';
|
import { showCollection, createNewEntry } from 'Actions/collections';
|
||||||
import { openMediaLibrary as actionOpenMediaLibrary } from 'Actions/mediaLibrary';
|
import { openMediaLibrary as actionOpenMediaLibrary } from 'Actions/mediaLibrary';
|
||||||
import MediaLibrary from 'MediaLibrary/MediaLibrary';
|
import MediaLibrary from 'MediaLibrary/MediaLibrary';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { resolvePath } from 'netlify-cms-lib-util';
|
import { resolvePath } from 'netlify-cms-lib-util';
|
||||||
import { currentBackend } from 'Backends/backend';
|
import { currentBackend } from 'src/backend';
|
||||||
import { getIntegrationProvider } from 'Integrations';
|
import { getIntegrationProvider } from 'Integrations';
|
||||||
import { selectIntegration } from 'Reducers';
|
import { selectIntegration } from 'Reducers';
|
||||||
|
|
||||||
|
@ -1,14 +1,26 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
|
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
|
||||||
const baseConfig = require('../../webpack.config.js');
|
const { getConfig, rules, plugins } = require('../../scripts/webpack.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...baseConfig,
|
...getConfig(),
|
||||||
context: path.join(__dirname, 'src'),
|
context: path.join(__dirname, 'src'),
|
||||||
entry: './index.js',
|
entry: './index.js',
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
...baseConfig.module.rules,
|
...Object.entries(rules)
|
||||||
|
.filter(([ key ]) => key !== 'js')
|
||||||
|
.map(([ _, rule ]) => rule()),
|
||||||
|
{
|
||||||
|
test: /\.js$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
configFile: path.join(__dirname, 'babel.config.js'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
include: [/redux-notifications/],
|
include: [/redux-notifications/],
|
||||||
@ -16,6 +28,16 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
plugins: [
|
||||||
|
...Object.entries(plugins)
|
||||||
|
.filter(([ key ]) => key !== 'friendlyErrors')
|
||||||
|
.map(([ _, plugin ]) => plugin()),
|
||||||
|
new FriendlyErrorsWebpackPlugin({
|
||||||
|
compilationSuccessInfo: {
|
||||||
|
messages: ['Netlify CMS is now running at http://localhost:8080'],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
devServer: {
|
devServer: {
|
||||||
contentBase: './example',
|
contentBase: './example',
|
||||||
watchContentBase: true,
|
watchContentBase: true,
|
||||||
@ -23,12 +45,4 @@ module.exports = {
|
|||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 8080,
|
port: 8080,
|
||||||
},
|
},
|
||||||
plugins: [
|
|
||||||
...baseConfig.plugins.filter(plugin => !plugin instanceof FriendlyErrorsWebpackPlugin),
|
|
||||||
new FriendlyErrorsWebpackPlugin({
|
|
||||||
compilationSuccessInfo: {
|
|
||||||
messages: ['Netlify CMS is now running at http://localhost:8080'],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
@ -1 +1,3 @@
|
|||||||
module.exports = require('../../webpack.config.js');
|
const { getConfig } = require('../../scripts/webpack.js');
|
||||||
|
|
||||||
|
module.exports = getConfig();
|
||||||
|
@ -1 +1,3 @@
|
|||||||
module.exports = require('../../webpack.config.js');
|
const { getConfig } = require('../../scripts/webpack.js');
|
||||||
|
|
||||||
|
module.exports = getConfig();
|
||||||
|
@ -1 +1,3 @@
|
|||||||
module.exports = require('../../webpack.config.js');
|
const { getConfig } = require('../../scripts/webpack.js');
|
||||||
|
|
||||||
|
module.exports = getConfig();
|
||||||
|
@ -1 +1,3 @@
|
|||||||
module.exports = require('../../webpack.config.js');
|
const { getConfig } = require('../../scripts/webpack.js');
|
||||||
|
|
||||||
|
module.exports = getConfig();
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
|
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
|
||||||
@ -6,25 +5,43 @@ const pkg = require(path.join(process.cwd(), 'package.json'));
|
|||||||
|
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
|
|
||||||
|
const rules = () => ({
|
||||||
|
js: () => ({
|
||||||
|
test: /\.js$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
configFile: path.resolve(`${__dirname}/../babel.config.js`),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
svg: () => ({
|
||||||
|
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
|
||||||
|
exclude: [/node_modules/],
|
||||||
|
use: 'svg-inline-loader',
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
const plugins = () => {
|
const plugins = () => {
|
||||||
const defaultPlugins = [
|
const defaultPlugins = {
|
||||||
new FriendlyErrorsWebpackPlugin(),
|
friendlyErrors: () => new FriendlyErrorsWebpackPlugin()
|
||||||
];
|
};
|
||||||
|
|
||||||
if (isProduction) {
|
if (isProduction) {
|
||||||
return [
|
return {
|
||||||
...defaultPlugins,
|
...defaultPlugins,
|
||||||
new webpack.SourceMapDevToolPlugin({
|
sourcemap: (config = {}) => new webpack.SourceMapDevToolPlugin({
|
||||||
filename: '[file].map',
|
filename: '[file].map',
|
||||||
moduleFilenameTemplate: info => path.posix.normalize(`../src/${info.resourcePath}`),
|
moduleFilenameTemplate: info => path.posix.normalize(`../src/${info.resourcePath}`),
|
||||||
noSources: true,
|
noSources: true,
|
||||||
}),
|
}),
|
||||||
];
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return {
|
||||||
...defaultPlugins,
|
...defaultPlugins,
|
||||||
];
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const stats = () => {
|
const stats = () => {
|
||||||
@ -44,7 +61,7 @@ const stats = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
const getConfig = () => ({
|
||||||
mode: isProduction ? 'production' : 'development',
|
mode: isProduction ? 'production' : 'development',
|
||||||
entry: './src/index.js',
|
entry: './src/index.js',
|
||||||
output: {
|
output: {
|
||||||
@ -55,27 +72,12 @@ module.exports = {
|
|||||||
umdNamedDefine: true,
|
umdNamedDefine: true,
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: Object.values(rules()).map(rule => rule()),
|
||||||
{
|
|
||||||
test: /\.js$/,
|
|
||||||
use: {
|
|
||||||
loader: 'babel-loader',
|
|
||||||
options: {
|
|
||||||
configFile: path.join(__dirname, 'babel.config.js'),
|
|
||||||
},
|
},
|
||||||
},
|
plugins: Object.values(plugins()).map(plugin => plugin),
|
||||||
exclude: /node_modules/,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
|
|
||||||
exclude: [/node_modules/],
|
|
||||||
loader: 'svg-inline-loader',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
plugins: plugins(),
|
|
||||||
devtool: !isProduction && 'source-map',
|
devtool: !isProduction && 'source-map',
|
||||||
target: 'web',
|
target: 'web',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exclude peer dependencies from package bundles.
|
* Exclude peer dependencies from package bundles.
|
||||||
*/
|
*/
|
||||||
@ -85,4 +87,10 @@ module.exports = {
|
|||||||
return peerDeps.some(isPeerDep) ? cb(null, request) : cb();
|
return peerDeps.some(isPeerDep) ? cb(null, request) : cb();
|
||||||
},
|
},
|
||||||
stats: stats(),
|
stats: stats(),
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getConfig,
|
||||||
|
rules: rules(),
|
||||||
|
plugins: plugins(),
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user