Skip to content

Commit 6800ea4

Browse files
committed
feat(module): compatibility with netlify-cms v2
Fixes #64
1 parent 3ac7b14 commit 6800ea4

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

Diff for: lib/entry.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/* global REQUIRE_EXTENSIONS */
1+
/* global REQUIRE_EXTENSIONS, REQUIRE_CSS, CSS_FILE */
22
/* eslint-disable import/order */
3+
34
function requireAll(r) {
45
r.keys().forEach(r);
56
}
@@ -9,9 +10,11 @@ const CMS = require("netlify-cms");
910
if (REQUIRE_EXTENSIONS) {
1011
requireAll(require.context("extensions/", true, /\.js$/));
1112
}
12-
const CSS = require("netlify-cms/dist/cms.css");
13+
14+
if (REQUIRE_CSS) {
15+
require(CSS_FILE);
16+
}
1317

1418
module.exports = {
15-
CMS,
16-
CSS
19+
CMS
1720
};

Diff for: src/webpack.config.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export default function webpackNetlifyCmsConfig(
2626
const PAGE_TEMPLATE = resolve(__dirname, "../lib/template", "index.html");
2727
const REQUIRE_EXTENSIONS = existsSync(EXTENSIONS_DIR) ? true : false;
2828
const HMR_CLIENT = resolve(__dirname, "../lib/hmr.client");
29+
const CSS_FILE = "netlify-cms/dist/cms.css";
30+
const REQUIRE_CSS = existsSync(resolve(__dirname, "node_modules", CSS_FILE))
31+
? true
32+
: false;
2933

3034
const config = {
3135
name,
@@ -65,7 +69,9 @@ export default function webpackNetlifyCmsConfig(
6569
chunksSortMode: "dependency"
6670
}),
6771
new webpack.DefinePlugin({
68-
REQUIRE_EXTENSIONS
72+
REQUIRE_EXTENSIONS,
73+
REQUIRE_CSS,
74+
CSS_FILE
6975
})
7076
]
7177
};

Diff for: test/__snapshots__/module.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ exports[`module admin 1`] = `
1010
<title>Content Manager</title>
1111
</head>
1212
<body>
13-
<script type=\\"text/javascript\\" src=\\"/admin/bundle.57440c18556c5552e2da.js\\"></script></body>
13+
<script type=\\"text/javascript\\" src=\\"/admin/bundle.c5488af0231117ae2d85.js\\"></script></body>
1414
</html>
1515
"
1616
`;

0 commit comments

Comments
 (0)