Skip to content

Commit

Permalink
feat(config): generated the config file for nuxt
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed Jul 26, 2020
1 parent 3c15078 commit ddcdcdc
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 3 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ overrides:
- files: example.js
rules:
import/no-extraneous-dependencies: off

- files: templates/*.js
rules:
import/no-unresolved: off
import/extensions: off
object-curly-spacing: off
comma-dangle: off
semi: off
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"version": "0.0.0-semantically-released",
"files": [
"example.js",
"lib/"
"lib/",
"templates/"
],
"publishConfig": {
"access": "public"
Expand Down
30 changes: 30 additions & 0 deletions src/config-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {promises as fs} from 'fs';
import {resolve} from 'path';
import sinon from 'sinon';
import {assert} from 'chai';
import any from '@travi/any';
import scaffoldConfig from './config';

suite('config', () => {
let sandbox;

setup(() => {
sandbox = sinon.createSandbox();

sandbox.stub(fs, 'copyFile');
});

teardown(() => sandbox.restore());

test('that the config file is created', async () => {
const projectRoot = any.string();

await scaffoldConfig({projectRoot});

assert.calledWith(
fs.copyFile,
resolve(__dirname, '..', 'templates', 'nuxt.config.js'),
`${projectRoot}/nuxt.config.js`
);
});
});
5 changes: 4 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export default function () {
import {promises as fs} from 'fs';
import {resolve} from 'path';

export default async function ({projectRoot}) {
await fs.copyFile(resolve(__dirname, '..', 'templates', 'nuxt.config.js'), `${projectRoot}/nuxt.config.js`);
}
59 changes: 59 additions & 0 deletions templates/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export default {
/*
** Nuxt rendering mode
** See https://nuxtjs.org/api/configuration-mode
*/
mode: 'spa',
/*
** Nuxt target
** See https://nuxtjs.org/api/configuration-target
*/
target: 'static',
/*
** Headers of the page
** See https://nuxtjs.org/api/configuration-head
*/
head: {
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: process.env.npm_package_description || '',
},
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
/*
** Global CSS
*/
css: [],
/*
** Plugins to load before mounting the App
** https://nuxtjs.org/guide/plugins
*/
plugins: [],
/*
** Auto import components
** See https://nuxtjs.org/api/configuration-components
*/
components: true,
/*
** Nuxt.js dev-modules
*/
buildModules: [
// Doc: https://github.com/nuxt-community/eslint-module
'@nuxtjs/eslint-module',
],
/*
** Nuxt.js modules
*/
modules: [],
/*
** Build configuration
** See https://nuxtjs.org/api/configuration-build/
*/
build: {},
}

0 comments on commit ddcdcdc

Please sign in to comment.