Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Separation of Concerns, Change lang to "scss" #41

Merged
merged 25 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7f51140
Merge branch 'master' into develop
omega-takai Apr 4, 2020
e97586b
Single File Components - 関心の分離 - Sass
omega-takai Apr 4, 2020
708a74d
ブレークポイントを視覚化
omega-takai Apr 4, 2020
3bd4fda
Update index.js
omega-takai Apr 9, 2020
d77ec77
Merge branch 'master' into develop
omega-takai Apr 9, 2020
bb36f36
Merge branch 'master' into develop
omega-takai Apr 22, 2020
5532c8c
Update nuxt.config.js
omega-takai Apr 22, 2020
a801336
Fix lint
omega-takai Apr 22, 2020
ec8bc06
update run-task
omega-takai Apr 22, 2020
0f6f58e
add -D husky lint-staged
omega-takai Apr 22, 2020
a7cad43
Change from modern-css-reset to destyle.css.
omega-takai Apr 22, 2020
77d0b51
fix import path
omega-takai Apr 22, 2020
62f5001
[Separation of Concerns] pages
omega-takai Apr 22, 2020
c5925c0
[Separation of Concerns] layouts
omega-takai Apr 22, 2020
f163712
delete seconds indicator
omega-takai Apr 22, 2020
a6eccd4
[Separation of Concerns] atom
omega-takai Apr 22, 2020
05337c6
[Separation of Concerns] Molecule
omega-takai Apr 22, 2020
671152d
[Separation of Concerns] Organism
omega-takai Apr 22, 2020
114ad84
[Separation of Concerns] Template
omega-takai Apr 22, 2020
c5bcbc1
$ yarn add -D sass2scss
omega-takai Apr 22, 2020
48027a4
Revert "$ yarn add -D sass2scss"
omega-takai Apr 22, 2020
b49accc
$ sass-convert --recursive ./src/ -F sass -T scss
omega-takai Apr 22, 2020
b75172e
Change the extension used from sass to scss
omega-takai Apr 22, 2020
b92bf95
Fix Sorybook Config
omega-takai Apr 22, 2020
814ecbb
remove sass files
omega-takai Apr 22, 2020
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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- Vuex
- Storybook
- template lang="pug"
- style lang="sass"
- style lang="scss"

## How to Develop

Expand Down Expand Up @@ -50,6 +50,8 @@ $ yarn generate:gh-pages
## References

- [Nuxt.js docs](https://ja.nuxtjs.org/)
- [Vue.js Lifecycle Diagram](https://jp.vuejs.org/v2/guide/instance.html#ライフサイクルダイアグラム)
- [Vue.js life cycle Diagram](https://jp.vuejs.org/v2/guide/instance.html#ライフサイクルダイアグラム)
- [Sass: sass:math](https://sass-lang.com/documentation/modules/math)
- [Pug](https://pugjs.org/api/getting-started.html)
- [Nuxt TypeScript docs](https://typescript.nuxtjs.org/ja/).
- [Nuxt Community TypeScript Template](https://github.com/nuxt-community/typescript-template).
54 changes: 10 additions & 44 deletions nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
import Sass from 'sass'
import Fiber from 'fibers'

const baseDir = process.env.BASE_DIR || '/'

// DEPLOY_ENV が GH_PAGES の場合のみ router.base = '/<repository-name>/' を追加する
// SEE: https://ja.nuxtjs.org/api/configuration-router/
// SEE: https://ja.nuxtjs.org/faq/github-pages/
// SEE: https://nuxtjs.org/api/configuration-builddir
const routerBase = process.env.BASE_DIR
? {
router: {
base: baseDir,
base: process.env.BASE_DIR,
},
generate: {
fallback: true, // '404.html' を使用したい場合
fallback: true,
dir: 'public',
},
}
: {}

export default {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: process.env.npm_package_name || '',
meta: [
Expand All @@ -37,74 +27,50 @@ export default {
},
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: `${baseDir}favicon.ico` },
{
rel: 'icon',
type: 'image/x-icon',
href: `${process.env.BASE_DIR || '/'}favicon.ico`,
},
{
rel: 'stylesheet',
href:
'https://fonts.googleapis.com/css?family=Noto+Sans+JP:400,700,900&display=swap&subset=japanese',
},
],
},
/*
** Customize the progress-bar color
*/
loading: { color: '#ddd' },
/*
** Global CSS
*/
css: ['@/assets/style/main.sass'],
/*
** Plugins to load before mounting the App
*/
css: ['@/assets/style/main.scss'],
plugins: [],
/*
** Nuxt.js dev-modules
*/
buildModules: [
// Doc: https://github.com/nuxt-community/eslint-module
'@nuxtjs/eslint-module',
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
'@nuxtjs/style-resources',
],
styleResources: {
sass: ['./assets/style/_chunk.sass'],
scss: ['./assets/style/_chunk.scss'],
},
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
axios: {},
vue: {
config: {
productionTip: false,
devtools: true,
},
},
/*
** Serve configuration
*/
server: {
port: 4000, // default: 3000
host: 'localhost', // default: localhost
},
/**
* configuration-srcdir
* configuration-srcDir
* DOC: https://ja.nuxtjs.org/api/configuration-srcdir/#__layout
*/
srcDir: 'src/',
/*
** Build configuration
*/
build: {
/*
** You can extend webpack config here
*/
babel: {
presets({ isServer }) {
return [
Expand Down
37 changes: 24 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,41 @@
"author": "Tomonari Takai",
"private": true,
"scripts": {
"predev": "yarn clean",
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"pregenerate:gh-pages": "yarn clean:generate",
"generate:gh-pages": "cross-env BASE_DIR=/NuxtBoilerplate/ nuxt generate",
"generate": "nuxt generate",
"generate:gh-pages": "cross-env BASE_DIR=/NuxtBoilerplate/ nuxt generate",
"lint": "eslint --ext .js,.vue .",
"clean:generate": "yarn clean docs",
"clean": "rimraf .nuxt dist .out",
"lint:fix": "yarn lint --fix",
"clean": "rimraf .nuxt dist .out public",
"test": "jest",
"prestorybook": "yarn clean",
"storybook": "start-storybook -c ./src/.storybook -p 6006",
"storybook:debug": "yarn storybook --debug-webpack",
"build-storybook": "build-storybook -c ./src/.storybook -o .out"
},
"lint-staged": {
"*.{js,vue}": "eslint --fix"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"post-merge": "yarn clean && yarn install",
"post-checkout": "yarn clean && yarn install",
"post-rebase": "yarn clean && yarn install",
"pre-auto-gc": "yarn clean"
}
},
"browserslist": [
"defaults",
"not < 1%",
"IE 11"
],
"dependencies": {
"@nuxtjs/axios": "5.9.7",
"@nuxtjs/style-resources": "1.0.0",
"core-js": "3.6.5",
"modern-css-reset": "1.1.0",
"destyle.css": "^1.0.11",
"nuxt": "2.12.2",
"vue-feather-icons": "5.0.0",
"vue-styled-components": "1.4.14"
Expand All @@ -51,7 +65,9 @@
"eslint-plugin-nuxt": "0.5.2",
"eslint-plugin-prettier": "3.1.3",
"fibers": "4.0.2",
"husky": "^4.2.5",
"jest": "25.3.0",
"lint-staged": "^10.1.7",
"node-sass": "4.13.1",
"prettier": "2.0.4",
"pug": "2.0.4",
Expand All @@ -61,10 +77,5 @@
"sass-loader": "8.0.2",
"sass-resources-loader": "2.0.3",
"vue-jest": "4.0.0-beta.2"
},
"browserslist": [
"defaults",
"not < 1%",
"IE 11"
]
}
}
2 changes: 1 addition & 1 deletion src/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { configure } from '@storybook/vue';

import '!style-loader!css-loader?sourceMap!sass-loader!../assets/style/main.sass';
import '!style-loader!css-loader?sourceMap!sass-loader!../assets/style/main.scss';

// automatically import all files ending in *.story.js
configure(require.context('../components', true, /\.story\.js$/), module);
101 changes: 41 additions & 60 deletions src/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
const path = require('path')

const cssLoader = {
loader: 'css-loader',
options: {
sourceMap: true,
},
}

const cssLoaderModule = {
loader: 'css-loader',
options: {
sourceMap: true,
modules: {
localIdentName: "[local]___[hash:base64:5]",
},
},
}
const sassLoader = {
loader: 'sass-loader',
options: {
sourceMap: true,
implementation: require('sass'),
sassOptions: {
fiber: require('fibers'),
},
},
}

const sassResourcesLoader = {
loader: 'sass-resources-loader',
options: {
resources: path.resolve(__dirname, '../assets/style/_chunk.scss')
}
}

// Export a function. Accept the base config as the only param.
// SEE: https://storybook.js.org/docs/configurations/custom-webpack-config/#full-control-mode
module.exports = async ({ config }) => {
Expand All @@ -10,81 +44,28 @@ module.exports = async ({ config }) => {
// Make whatever fine-grained changes you need
config.module.rules.push(
{
test: /\.sass$/,
test: /\.scss$/,
oneOf: [
{
// this matches `<style lang="sass" module>`
resourceQuery: /module/,
use: [
'vue-style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
modules: {
localIdentName: "[local]___[hash:base64:5]",
},
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
implementation: require('sass'),
sassOptions: {
indentedSyntax: true,
fiber: require('fibers'),
},
},
},
{
loader: 'sass-resources-loader',
options: {
resources: path.resolve(__dirname, '../assets/style/_chunk.sass')
}
},
cssLoaderModule,
sassLoader,
sassResourcesLoader,
],
},
{
// this matches plain `<style lang="sass">` or `<style lang="sass" scoped>`
use: [
'vue-style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
implementation: require('sass'),
sassOptions: {
indentedSyntax: true,
fiber: require('fibers'),
// includePaths: [path.resolve(__dirname, '../assets/style/_chunk.sass')]
},
},
},
{
loader: 'sass-resources-loader',
options: {
resources: path.resolve(__dirname, '../assets/style/_chunk.sass')
}
},
cssLoader,
sassLoader,
sassResourcesLoader,
],
},
],
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader',
],
},
{
test: /\.css$/,
sideEffects: true,
Expand Down
8 changes: 0 additions & 8 deletions src/assets/style/_chunk.sass

This file was deleted.

8 changes: 8 additions & 0 deletions src/assets/style/_chunk.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// global
// chunk.sass
// pre-processer can import SCSS
// vue-style-loader can't import SCSS
@import "scss/_base.scss";
@import "scss/_computation.scss";
@import "scss/_variable.scss";
@import "scss/_mediaQuery.scss";
Loading