diff --git a/.eslintignore b/.eslintignore index 801d56deaa..75a030c95e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,4 @@ app node_modules dist .nuxt +examples/coffeescript/pages/index.vue diff --git a/examples/with-coffee/README.md b/examples/coffeescript/README.md similarity index 87% rename from examples/with-coffee/README.md rename to examples/coffeescript/README.md index 601a17bbb6..60a641df16 100644 --- a/examples/with-coffee/README.md +++ b/examples/coffeescript/README.md @@ -1,6 +1,6 @@ -# with-coffee +# CoffeeScript -> Nuxt.js project +> Nuxt.js project with CoffeeScript ## Build Setup diff --git a/examples/with-coffee/components/Logo.vue b/examples/coffeescript/components/Logo.vue similarity index 100% rename from examples/with-coffee/components/Logo.vue rename to examples/coffeescript/components/Logo.vue diff --git a/examples/with-coffee/layouts/default.vue b/examples/coffeescript/layouts/default.vue similarity index 100% rename from examples/with-coffee/layouts/default.vue rename to examples/coffeescript/layouts/default.vue diff --git a/examples/coffeescript/modules/coffeescript.js b/examples/coffeescript/modules/coffeescript.js new file mode 100644 index 0000000000..a6a0a6c040 --- /dev/null +++ b/examples/coffeescript/modules/coffeescript.js @@ -0,0 +1,23 @@ +module.exports = function () { + // Add .coffee extension for store, middleware and more + this.nuxt.options.extensions.push('coffee') + // Extend build + const coffeeLoader = { + test: /\.coffee$/, + loader: 'coffee-loader' + } + this.extendBuild(config => { + // Add CoffeeScruot loader + config.module.rules.push(coffeeLoader) + // Add CoffeeScript loader for vue files + for (let rule of config.module.rules) { + if (rule.loader === 'vue-loader') { + rule.options.loaders.coffee = coffeeLoader + } + } + // Add .coffee extension in webpack resolve + if (config.resolve.extensions.indexOf('.coffee') === -1) { + config.resolve.extensions.push('.coffee') + } + }) +} diff --git a/examples/with-coffee/nuxt.config.js b/examples/coffeescript/nuxt.config.js similarity index 62% rename from examples/with-coffee/nuxt.config.js rename to examples/coffeescript/nuxt.config.js index f2899df1f1..67afea59ff 100644 --- a/examples/with-coffee/nuxt.config.js +++ b/examples/coffeescript/nuxt.config.js @@ -3,7 +3,7 @@ module.exports = { ** Headers of the page */ head: { - title: 'with-coffee', + title: 'Nuxt with CoffeeScript', meta: [ { charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' }, @@ -18,16 +18,7 @@ module.exports = { */ loading: { color: '#3B8070' }, /* - ** Build configuration + ** Modules */ - extensions: ['coffee'], - build: { - extend (config, ctx) { - config.resolve.extensions.push('.ts') - config.module.rules.push({ - test: /\.coffee$/, - loader: 'coffee-loader' - }) - } - } + modules: ['~/modules/coffeescript'] } diff --git a/examples/coffeescript/package.json b/examples/coffeescript/package.json new file mode 100644 index 0000000000..759d04ff0f --- /dev/null +++ b/examples/coffeescript/package.json @@ -0,0 +1,19 @@ +{ + "name": "coffeescript", + "version": "1.0.0", + "description": "Nuxt.js with CoffeeScript", + "author": "Alex Ananiev ", + "private": true, + "scripts": { + "dev": "nuxt", + "build": "nuxt build", + "start": "nuxt start" + }, + "dependencies": { + "nuxt": "latest" + }, + "devDependencies": { + "coffee-loader": "^0.8.0", + "coffeescript": "^2.0.1" + } +} diff --git a/examples/with-coffee/pages/README.md b/examples/coffeescript/pages/README.md similarity index 100% rename from examples/with-coffee/pages/README.md rename to examples/coffeescript/pages/README.md diff --git a/examples/with-coffee/pages/index.vue b/examples/coffeescript/pages/index.vue similarity index 100% rename from examples/with-coffee/pages/index.vue rename to examples/coffeescript/pages/index.vue diff --git a/examples/with-coffee/static/favicon.ico b/examples/coffeescript/static/favicon.ico similarity index 100% rename from examples/with-coffee/static/favicon.ico rename to examples/coffeescript/static/favicon.ico diff --git a/examples/with-coffee/store/index.coffee b/examples/coffeescript/store/index.coffee similarity index 100% rename from examples/with-coffee/store/index.coffee rename to examples/coffeescript/store/index.coffee diff --git a/examples/with-coffee/.editorconfig b/examples/with-coffee/.editorconfig deleted file mode 100644 index 9142239769..0000000000 --- a/examples/with-coffee/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -# editorconfig.org -root = true - -[*] -indent_size = 2 -indent_style = space -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false diff --git a/examples/with-coffee/.eslintrc.js b/examples/with-coffee/.eslintrc.js deleted file mode 100644 index b44e099cbb..0000000000 --- a/examples/with-coffee/.eslintrc.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - root: true, - parser: 'babel-eslint', - env: { - browser: true, - node: true - }, - extends: 'standard', - // required to lint *.vue files - plugins: [ - 'html' - ], - // add your custom rules here - rules: {}, - globals: {} -} diff --git a/examples/with-coffee/.gitignore b/examples/with-coffee/.gitignore deleted file mode 100644 index 7ee6115053..0000000000 --- a/examples/with-coffee/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -# dependencies -node_modules - -# logs -npm-debug.log - -# Nuxt build -.nuxt - -# Nuxt generate -dist diff --git a/examples/with-coffee/assets/README.md b/examples/with-coffee/assets/README.md deleted file mode 100644 index c67cf2e260..0000000000 --- a/examples/with-coffee/assets/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# ASSETS - -This directory contains your un-compiled assets such as LESS, SASS, or JavaScript. - -More information about the usage of this directory in the documentation: -https://nuxtjs.org/guide/assets#webpacked - -**This directory is not required, you can delete it if you don't want to use it.** diff --git a/examples/with-coffee/components/README.md b/examples/with-coffee/components/README.md deleted file mode 100644 index d7768ddb5f..0000000000 --- a/examples/with-coffee/components/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# COMPONENTS - -The components directory contains your Vue.js Components. -Nuxt.js doesn't supercharge these components. - -**This directory is not required, you can delete it if you don't want to use it.** diff --git a/examples/with-coffee/layouts/README.md b/examples/with-coffee/layouts/README.md deleted file mode 100644 index 83d09caee8..0000000000 --- a/examples/with-coffee/layouts/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# LAYOUTS - -This directory contains your Application Layouts. - -More information about the usage of this directory in the documentation: -https://nuxtjs.org/guide/views#layouts - -**This directory is not required, you can delete it if you don't want to use it.** diff --git a/examples/with-coffee/middleware/README.md b/examples/with-coffee/middleware/README.md deleted file mode 100644 index edb9129e28..0000000000 --- a/examples/with-coffee/middleware/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# MIDDLEWARE - -This directory contains your Application Middleware. -The middleware lets you define custom function to be ran before rendering a page or a group of pages (layouts). - -More information about the usage of this directory in the documentation: -https://nuxtjs.org/guide/routing#middleware - -**This directory is not required, you can delete it if you don't want to use it.** diff --git a/examples/with-coffee/package.json b/examples/with-coffee/package.json deleted file mode 100644 index 7554f4a84e..0000000000 --- a/examples/with-coffee/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "with-coffee", - "version": "1.0.0", - "description": "Nuxt.js with CoffeeScript", - "author": "Alex Ananiev ", - "private": true, - "scripts": { - "dev": "nuxt", - "build": "nuxt build", - "start": "nuxt start", - "generate": "nuxt generate", - "lint": "eslint --ext .js,.vue --ignore-path .gitignore .", - "precommit": "npm run lint" - }, - "dependencies": { - "nuxt": "latest" - }, - "devDependencies": { - "babel-eslint": "^7.2.3", - "coffee-loader": "^0.8.0", - "coffeescript": "^2.0.1", - "eslint": "^4.3.0", - "eslint-config-standard": "^10.2.1", - "eslint-loader": "^1.9.0", - "eslint-plugin-html": "^3.1.1", - "eslint-plugin-import": "^2.7.0", - "eslint-plugin-node": "^5.1.1", - "eslint-plugin-promise": "^3.5.0", - "eslint-plugin-standard": "^3.0.1" - } -} diff --git a/examples/with-coffee/plugins/README.md b/examples/with-coffee/plugins/README.md deleted file mode 100644 index ec39a25e3f..0000000000 --- a/examples/with-coffee/plugins/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# PLUGINS - -This directory contains your Javascript plugins that you want to run before instantiating the root vue.js application. - -More information about the usage of this directory in the documentation: -https://nuxtjs.org/guide/plugins - -**This directory is not required, you can delete it if you don't want to use it.** diff --git a/examples/with-coffee/static/README.md b/examples/with-coffee/static/README.md deleted file mode 100644 index 66fe23aac1..0000000000 --- a/examples/with-coffee/static/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# STATIC - -This directory contains your static files. -Each file inside this directory is mapped to /. - -Example: /static/robots.txt is mapped as /robots.txt. - -More information about the usage of this directory in the documentation: -https://nuxtjs.org/guide/assets#static - -**This directory is not required, you can delete it if you don't want to use it.** diff --git a/examples/with-coffee/store/README.md b/examples/with-coffee/store/README.md deleted file mode 100644 index b9a0b7e4c8..0000000000 --- a/examples/with-coffee/store/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# STORE - -This directory contains your Vuex Store files. -Vuex Store option is implemented in the Nuxt.js framework. -Creating a index.js file in this directory activate the option in the framework automatically. - -More information about the usage of this directory in the documentation: -https://nuxtjs.org/guide/vuex-store - -**This directory is not required, you can delete it if you don't want to use it.**