Skip to content

Support Nuxt.js >= 2.0.0 #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@
"dist"
],
"dependencies": {
"friendly-errors-webpack-plugin": "^1.7.0",
"js-yaml": "^3.10.0",
"mini-css-extract-plugin": "^0.5.0",
"needlepoint": "^1.0.5",
"style-loader": "^0.23.0"
},
"peerDependencies": {
"netlify-cms": ">=0.4.0"
},
"devDependencies": {
"@nuxt/common": "^2.3.4",
"babel-cli": "^6.26.0",
"babel-eslint": "^10.0.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
Expand All @@ -52,7 +55,7 @@
"koa-static": "^5.0.0",
"lint-staged": "^8.0.4",
"netlify-cms": "2.3.3",
"nuxt": "^1.4.2",
"nuxt": "^2.0.0",
"prettier": "^1.7.0",
"request-promise-native": "^1.0.4",
"standard-version": "^4.2.0"
Expand Down
6 changes: 3 additions & 3 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { join } from "path";
/* covered by nuxt */
import { move } from "fs-extra";
import _ from "lodash";
import { Utils } from "nuxt";
import { r, urlJoin } from "@nuxt/common";
import chokidar from "chokidar";
import pify from "pify";
import webpack from "webpack";
Expand Down Expand Up @@ -137,7 +137,7 @@ export default function NetlifyCmsModule(moduleOptions) {
path: config.adminPath,
handler: async (req, res) => {
if (this.nuxt.renderer.netlifyWebpackDevMiddleware) {
debug(`requesting url: ${Utils.urlJoin(config.adminPath, req.url)}`);
debug(`requesting url: ${urlJoin(config.adminPath, req.url)}`);
await this.nuxt.renderer.netlifyWebpackDevMiddleware(req, res);
}
if (this.nuxt.renderer.netlifyWebpackHotMiddleware) {
Expand All @@ -147,7 +147,7 @@ export default function NetlifyCmsModule(moduleOptions) {
});

// Start watching config file
const patterns = [Utils.r(configManager.cmsConfigFileName)];
const patterns = [r(configManager.cmsConfigFileName)];

const options = {
...this.options.watchers.chokidar,
Expand Down
18 changes: 9 additions & 9 deletions src/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { existsSync } from "fs";
import { resolve } from "path";

import { Utils } from "nuxt";
import { urlJoin } from "@nuxt/common";
/* eslint-disable import/no-extraneous-dependencies */
/* covered by nuxt */
import webpack from "webpack";
import HTMLPlugin from "html-webpack-plugin";
import ExtractTextPlugin from "extract-text-webpack-plugin";
import MiniCssExtractPlugin from "mini-css-extract-plugin";
import FriendlyErrorsWebpackPlugin from "friendly-errors-webpack-plugin";

export default function webpackNetlifyCmsConfig(
Expand All @@ -16,11 +16,11 @@ export default function webpackNetlifyCmsConfig(
) {
const ENTRY = resolve(__dirname, "../lib/entry");
const BUILD_DIR = moduleConfig.buildDir;
const CHUNK_FILENAME = nuxtOptions.build.filenames.chunk;
const PUBLIC_PATH = Utils.urlJoin(
nuxtOptions.router.base,
moduleConfig.adminPath
);
const CHUNK_FILENAME = nuxtOptions.build.filenames.chunk({
isDev: nuxtOptions.dev,
isModern: nuxtOptions.modern
});
const PUBLIC_PATH = urlJoin(nuxtOptions.router.base, moduleConfig.adminPath);
const EXTENSIONS_DIR = moduleConfig.moduleConfigDir;
const PAGE_TITLE = moduleConfig.adminTitle;
const PAGE_TEMPLATE = resolve(__dirname, "../lib/template", "index.html");
Expand All @@ -43,7 +43,7 @@ export default function webpackNetlifyCmsConfig(
publicPath: PUBLIC_PATH
},
module: {
loaders: [
rules: [
{ test: /\.css$/, loader: "style-loader!css-loader" },
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
Expand Down Expand Up @@ -98,7 +98,7 @@ export default function webpackNetlifyCmsConfig(
// Minify and optimize the JavaScript
config.plugins.push(
// CSS extraction
new ExtractTextPlugin({
new MiniCssExtractPlugin({
filename: "style.[contenthash].css"
}),
// This is needed in webpack 2 for minify CSS
Expand Down