chore: move local dev env to netlify-cms (#1538)

This commit is contained in:
Shawn Erquhart 2018-07-28 17:11:29 -04:00 committed by GitHub
parent f7dba877af
commit 892c51ce86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 50 additions and 496 deletions

View File

Before

Width:  |  Height:  |  Size: 808 KiB

After

Width:  |  Height:  |  Size: 808 KiB

View File

@ -4,6 +4,8 @@ backend:
display_url: https://example.com display_url: https://example.com
media_folder: "assets/uploads" media_folder: "assets/uploads"
publish_mode: editorial_workflow
collections: # A list of collections the CMS should be able to edit collections: # A list of collections the CMS should be able to edit
- name: "posts" # Used in routes, ie.: /admin/collections/:slug/edit - name: "posts" # Used in routes, ie.: /admin/collections/:slug/edit
label: "Posts" # Used in the UI label: "Posts" # Used in the UI

View File

@ -79,7 +79,7 @@
</head> </head>
<body> <body>
<script src="netlify-cms.js"></script> <script src="dist/netlify-cms.js"></script>
<script> <script>
var PostPreview = createClass({ var PostPreview = createClass({
render: function() { render: function() {

View File

Before

Width:  |  Height:  |  Size: 310 KiB

After

Width:  |  Height:  |  Size: 310 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,6 @@
"dist/" "dist/"
], ],
"scripts": { "scripts": {
"watch": "webpack-dev-server --hot --open",
"build": "cross-env NODE_ENV=production webpack" "build": "cross-env NODE_ENV=production webpack"
}, },
"keywords": [ "keywords": [
@ -70,10 +69,8 @@
"devDependencies": { "devDependencies": {
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
"css-loader": "^1.0.0", "css-loader": "^1.0.0",
"friendly-errors-webpack-plugin": "^1.7.0",
"to-string-loader": "^1.1.5", "to-string-loader": "^1.1.5",
"webpack": "^4.16.1", "webpack": "^4.16.1",
"webpack-cli": "^3.1.0", "webpack-cli": "^3.1.0"
"webpack-dev-server": "^3.1.5"
} }
} }

View File

@ -1,40 +0,0 @@
import { registerBackend, registerWidget, registerEditorComponent } from 'Lib/registry';
import { GitHubBackend } from 'netlify-cms-backend-github';
import { GitLabBackend } from 'netlify-cms-backend-gitlab';
import { GitGatewayBackend } from 'netlify-cms-backend-git-gateway';
import { BitbucketBackend } from 'netlify-cms-backend-bitbucket';
import { TestBackend } from 'netlify-cms-backend-test';
import { BooleanControl } from 'netlify-cms-widget-boolean';
import { DateControl, DatePreview } from 'netlify-cms-widget-date';
import { DateTimeControl, DateTimePreview } from 'netlify-cms-widget-datetime';
import { FileControl, FilePreview } from 'netlify-cms-widget-file';
import { ImageControl, ImagePreview } from 'netlify-cms-widget-image';
import { ListControl, ListPreview } from 'netlify-cms-widget-list';
import { ObjectControl, ObjectPreview } from 'netlify-cms-widget-object';
import { MarkdownControl, MarkdownPreview } from 'netlify-cms-widget-markdown';
import { NumberControl, NumberPreview } from 'netlify-cms-widget-number';
import { RelationControl, RelationPreview } from 'netlify-cms-widget-relation';
import { StringControl, StringPreview } from 'netlify-cms-widget-string';
import { SelectControl, SelectPreview } from 'netlify-cms-widget-select';
import { TextControl, TextPreview } from 'netlify-cms-widget-text';
import image from 'netlify-cms-editor-component-image';
registerBackend('git-gateway', GitGatewayBackend);
registerBackend('github', GitHubBackend);
registerBackend('gitlab', GitLabBackend);
registerBackend('test-repo', TestBackend);
registerBackend('bitbucket', BitbucketBackend);
registerWidget('boolean', BooleanControl);
registerWidget('date', DateControl, DatePreview);
registerWidget('datetime', DateTimeControl, DateTimePreview);
registerWidget('file', FileControl, FilePreview);
registerWidget('image', ImageControl, ImagePreview);
registerWidget('list', ListControl, ListPreview);
registerWidget('markdown', MarkdownControl, MarkdownPreview);
registerWidget('number', NumberControl, NumberPreview);
registerWidget('object', ObjectControl, ObjectPreview);
registerWidget('relation', RelationControl, RelationPreview);
registerWidget('string', StringControl, StringPreview);
registerWidget('text', TextControl, TextPreview);
registerWidget('select', SelectControl, SelectPreview);
registerEditorComponent(image);

View File

@ -6,23 +6,12 @@ const { getConfig, rules, plugins } = require('../../scripts/webpack.js');
const isProduction = process.env.NODE_ENV === 'production'; const isProduction = process.env.NODE_ENV === 'production';
const entry = () => { const baseConfig = getConfig();
const defaultEntry = ['./index.js'];
if (isProduction) {
return defaultEntry;
}
return [
...defaultEntry,
'../scripts/load-extensions.js',
];
};
module.exports = { module.exports = {
...getConfig(), ...baseConfig,
context: path.join(__dirname, 'src'), context: path.join(__dirname, 'src'),
entry: entry(), entry: ['./index.js'],
module: { module: {
rules: [ rules: [
...Object.entries(rules) ...Object.entries(rules)
@ -46,24 +35,10 @@ module.exports = {
], ],
}, },
plugins: [ plugins: [
...Object.entries(plugins) ...baseConfig.plugins,
.filter(([ key ]) => key !== 'friendlyErrors')
.map(([ _, plugin ]) => plugin()),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
NETLIFY_CMS_VERSION: null, NETLIFY_CMS_VERSION: null,
NETLIFY_CMS_CORE_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`), NETLIFY_CMS_CORE_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`),
}), }),
new FriendlyErrorsWebpackPlugin({
compilationSuccessInfo: {
messages: ['Netlify CMS is now running at http://localhost:8080'],
},
}),
], ],
devServer: {
contentBase: './example',
watchContentBase: true,
quiet: true,
host: 'localhost',
port: 8080,
},
}; };

Binary file not shown.

Before

Width:  |  Height:  |  Size: 808 KiB

View File

@ -1,171 +0,0 @@
backend:
name: test-repo
display_url: https://example.com
media_folder: "assets/uploads"
collections: # A list of collections the CMS should be able to edit
- name: "posts" # Used in routes, ie.: /admin/collections/:slug/edit
label: "Posts" # Used in the UI
label_singular: "Post" # Used in the UI, ie: "New Post"
description: >
The description is a great place for tone setting, high level information, and editing
guidelines that are specific to a collection.
folder: "_posts"
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
create: true # Allow users to create new documents in this collection
fields: # The fields each document in this collection have
- {label: "Title", name: "title", widget: "string", tagname: "h1"}
- {label: "Publish Date", name: "date", widget: "datetime", format: "YYYY-MM-DD hh:mma"}
- {label: "Cover Image", name: "image", widget: "image", required: false, tagname: ""}
- {label: "Body", name: "body", widget: "markdown"}
meta:
- {label: "SEO Description", name: "description", widget: "text"}
- name: "faq" # Used in routes, ie.: /admin/collections/:slug/edit
label: "FAQ" # Used in the UI
folder: "_faqs"
create: true # Allow users to create new documents in this collection
fields: # The fields each document in this collection have
- {label: "Question", name: "title", widget: "string", tagname: "h1"}
- {label: "Answer", name: "body", widget: "markdown"}
- name: "settings"
label: "Settings"
delete: false # Prevent users from deleting documents in this collection
editor:
preview: false
files:
- name: "general"
label: "Site Settings"
file: "_data/settings.json"
description: "General Site Settings"
fields:
- {label: "Global title", name: "site_title", widget: "string"}
- label: "Post Settings"
name: posts
widget: "object"
fields:
- {label: "Number of posts on frontpage", name: front_limit, widget: number}
- {label: "Default Author", name: author, widget: string}
- {label: "Default Thumbnail", name: thumb, widget: image, class: "thumb"}
- name: "authors"
label: "Authors"
file: "_data/authors.yml"
description: "Author descriptions"
fields:
- name: authors
label: Authors
label_singular: "Author"
widget: list
fields:
- {label: "Name", name: "name", widget: "string"}
- {label: "Description", name: "description", widget: "markdown"}
- name: "kitchenSink" # all the things in one entry, for documentation and quick testing
label: "Kitchen Sink"
folder: "_sink"
create: true
fields:
- label: "Related Post"
name: "post"
widget: "relationKitchenSinkPost"
collection: "posts"
displayFields: ["title", "date"]
searchFields: ["title", "body"]
valueField: "title"
- {label: "Title", name: "title", widget: "string"}
- {label: "Boolean", name: "boolean", widget: "boolean", default: true}
- {label: "Text", name: "text", widget: "text"}
- {label: "Number", name: "number", widget: "number"}
- {label: "Markdown", name: "markdown", widget: "markdown"}
- {label: "Datetime", name: "datetime", widget: "datetime"}
- {label: "Date", name: "date", widget: "date"}
- {label: "Image", name: "image", widget: "image"}
- {label: "File", name: "file", widget: "file"}
- {label: "Select", name: "select", widget: "select", options: ["a", "b", "c"]}
- {label: "Hidden", name: "hidden", widget: "hidden", default: "hidden"}
- label: "Object"
name: "object"
widget: "object"
fields:
- label: "Related Post"
name: "post"
widget: "relationKitchenSinkPost"
collection: "posts"
searchFields: ["title", "body"]
valueField: "title"
- {label: "String", name: "string", widget: "string"}
- {label: "Boolean", name: "boolean", widget: "boolean", default: false}
- {label: "Text", name: "text", widget: "text"}
- {label: "Number", name: "number", widget: "number"}
- {label: "Markdown", name: "markdown", widget: "markdown"}
- {label: "Datetime", name: "datetime", widget: "datetime"}
- {label: "Date", name: "date", widget: "date"}
- {label: "Image", name: "image", widget: "image"}
- {label: "File", name: "file", widget: "file"}
- {label: "Select", name: "select", widget: "select", options: ["a", "b", "c"]}
- label: "List"
name: "list"
widget: "list"
fields:
- {label: "String", name: "string", widget: "string"}
- {label: "Boolean", name: "boolean", widget: "boolean"}
- {label: "Text", name: "text", widget: "text"}
- {label: "Number", name: "number", widget: "number"}
- {label: "Markdown", name: "markdown", widget: "markdown"}
- {label: "Datetime", name: "datetime", widget: "datetime"}
- {label: "Date", name: "date", widget: "date"}
- {label: "Image", name: "image", widget: "image"}
- {label: "File", name: "file", widget: "file"}
- {label: "Select", name: "select", widget: "select", options: ["a", "b", "c"]}
- label: "Object"
name: "object"
widget: "object"
fields:
- {label: "String", name: "string", widget: "string"}
- {label: "Boolean", name: "boolean", widget: "boolean"}
- {label: "Text", name: "text", widget: "text"}
- {label: "Number", name: "number", widget: "number"}
- {label: "Markdown", name: "markdown", widget: "markdown"}
- {label: "Datetime", name: "datetime", widget: "datetime"}
- {label: "Date", name: "date", widget: "date"}
- {label: "Image", name: "image", widget: "image"}
- {label: "File", name: "file", widget: "file"}
- {label: "Select", name: "select", widget: "select", options: ["a", "b", "c"]}
- label: "List"
name: "list"
widget: "list"
fields:
- label: "Related Post"
name: "post"
widget: "relationKitchenSinkPost"
collection: "posts"
searchFields: ["title", "body"]
valueField: "title"
- {label: "String", name: "string", widget: "string"}
- {label: "Boolean", name: "boolean", widget: "boolean"}
- {label: "Text", name: "text", widget: "text"}
- {label: "Number", name: "number", widget: "number"}
- {label: "Markdown", name: "markdown", widget: "markdown"}
- {label: "Datetime", name: "datetime", widget: "datetime"}
- {label: "Date", name: "date", widget: "date"}
- {label: "Image", name: "image", widget: "image"}
- {label: "File", name: "file", widget: "file"}
- {label: "Select", name: "select", widget: "select", options: ["a", "b", "c"]}
- {label: "Hidden", name: "hidden", widget: "hidden", default: "hidden"}
- label: "Object"
name: "object"
widget: "object"
fields:
- {label: "String", name: "string", widget: "string"}
- {label: "Boolean", name: "boolean", widget: "boolean"}
- {label: "Text", name: "text", widget: "text"}
- {label: "Number", name: "number", widget: "number"}
- {label: "Markdown", name: "markdown", widget: "markdown"}
- {label: "Datetime", name: "datetime", widget: "datetime"}
- {label: "Date", name: "date", widget: "date"}
- {label: "Image", name: "image", widget: "image"}
- {label: "File", name: "file", widget: "file"}
- {label: "Select", name: "select", widget: "select", options: ["a", "b", "c"]}

View File

@ -1,21 +0,0 @@
html,
body {
color: #444;
font-size: 14px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
body {
padding: 20px;
}
h1 {
margin-top: 20px;
color: #666;
font-weight: bold;
font-size: 32px;
}
img {
max-width: 100%;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -7,6 +7,7 @@
"bugs": "https://github.com/netlify/netlify-cms/issues", "bugs": "https://github.com/netlify/netlify-cms/issues",
"main": "dist/netlify-cms.js", "main": "dist/netlify-cms.js",
"scripts": { "scripts": {
"watch": "webpack-dev-server --hot --open",
"build": "cross-env NODE_ENV=production webpack" "build": "cross-env NODE_ENV=production webpack"
}, },
"keywords": [ "keywords": [
@ -42,7 +43,9 @@
}, },
"devDependencies": { "devDependencies": {
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
"friendly-errors-webpack-plugin": "^1.7.0",
"webpack": "^4.16.1", "webpack": "^4.16.1",
"webpack-cli": "^3.1.0" "webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.5"
} }
} }

View File

@ -1,6 +1,8 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const pkg = require('./package.json'); const pkg = require('./package.json');
const { plugins } = require('../../scripts/webpack');
const coreWebpackConfig = require('../netlify-cms-core/webpack.config.js'); const coreWebpackConfig = require('../netlify-cms-core/webpack.config.js');
const isProduction = process.env.NODE_ENV === 'production'; const isProduction = process.env.NODE_ENV === 'production';
@ -10,15 +12,30 @@ const baseConfig = {
context: path.join(__dirname, 'src'), context: path.join(__dirname, 'src'),
entry: './index.js', entry: './index.js',
plugins: [ plugins: [
...coreWebpackConfig.plugins.filter(plugin => !(plugin instanceof webpack.DefinePlugin)), ...Object.entries(plugins)
.filter(([ key ]) => key !== 'friendlyErrors')
.map(([ _, plugin ]) => plugin()),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
NETLIFY_CMS_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`), NETLIFY_CMS_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`),
NETLIFY_CMS_CORE_VERSION: null, NETLIFY_CMS_CORE_VERSION: null,
}), }),
new FriendlyErrorsWebpackPlugin({
compilationSuccessInfo: {
messages: ['Netlify CMS is now running at http://localhost:8080'],
},
}),
], ],
devServer: {
contentBase: '../../dev-test',
watchContentBase: true,
quiet: true,
host: 'localhost',
port: 8080,
},
}; };
module.exports = [ if (isProduction) {
module.exports = [
baseConfig, baseConfig,
/** /**
@ -36,4 +53,7 @@ module.exports = [
filename: 'dist/cms.js', filename: 'dist/cms.js',
}, },
}, },
]; ];
} else {
module.exports = baseConfig;
}