Skip to content
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

LESSからSCSSへの移行 #76

Merged
merged 37 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1b78945
yarn add metalsmith-postcss2 @csstools/postcss-sass
sounisi5011 Oct 17, 2019
7b5e202
yarn add postcss-scss
sounisi5011 Oct 17, 2019
8bdb435
PostCSSの設定ファイルを追加
sounisi5011 Oct 17, 2019
95a868d
metalsmith-postcss2プラグインを使用するコードに変更
sounisi5011 Oct 17, 2019
96542b1
コミット時にSCSSファイルを自動整形する設定を追加
sounisi5011 Oct 17, 2019
3cb845d
LESSの定義を移植したSCSSファイルを追加
sounisi5011 Oct 17, 2019
298ca18
yarn add node-sass-package-importer
sounisi5011 Oct 18, 2019
3b19748
postcss-sassにimporterオプションを追加
sounisi5011 Oct 18, 2019
2f6f74d
SCSSファイルの構文を修正
sounisi5011 Oct 18, 2019
0356d31
node_modulesディレクトリ内のファイルを読み込むように修正
sounisi5011 Oct 18, 2019
db55589
SCSSで使えない構文を修正
sounisi5011 Oct 18, 2019
4878cb3
Font Awesomeの誤りを修正
sounisi5011 Oct 18, 2019
e4a8841
PostCSSのSourceMap生成を無効化
sounisi5011 Oct 18, 2019
c7bcbdc
SCSSの構文を修正
sounisi5011 Oct 18, 2019
dade445
autoprefixerがgrid-templateにベンダープレフィックスを追加しない問題を修正
sounisi5011 Oct 18, 2019
993815f
fa-font-path変数の上書き構文を修正
sounisi5011 Oct 18, 2019
3ab8227
セレクタの結合が正しく機能しない問題を修正
sounisi5011 Oct 18, 2019
ffe3892
fontawesomeの不要なスタイル定義の読み込みを削除
sounisi5011 Oct 18, 2019
64e289d
yarn remove node-sass-package-importer metalsmith-postcss
sounisi5011 Oct 18, 2019
54e772e
SCSSでpreloadDependencies等が動作するように修正
sounisi5011 Oct 18, 2019
852a1d9
LESSファイルを削除
sounisi5011 Oct 18, 2019
dc806dd
セレクタの結合に@at-rootを使用
sounisi5011 Oct 18, 2019
536c3c3
yarn add metalsmith-dart-sass
sounisi5011 Oct 24, 2019
1703119
metalsmith-dart-sassプラグインを使用するコードを追加
sounisi5011 Oct 24, 2019
392acca
PostCSSの設定ファイルから、SCSSを変換するための設定を削除
sounisi5011 Oct 24, 2019
d9e24ce
postcss2プラグインのpatternオプションを削除
sounisi5011 Oct 24, 2019
d1c3fc5
PostCSSのSourceMap生成を有効化
sounisi5011 Oct 24, 2019
4173105
dart-sassプラグインのSassオプションでsourceMapContentsフラグを有効化
sounisi5011 Oct 24, 2019
0588cea
PostCSSのSourceMap生成を無効化
sounisi5011 Oct 24, 2019
6ea178c
dependenciesKeyオプションをpostcss2プラグインからdart-sassプラグインに移動
sounisi5011 Oct 24, 2019
95bfd5f
"_"が接頭辞のディレクトリ内のSCSSファイルを変換対象から除外
sounisi5011 Oct 24, 2019
299e2b0
Lessを変換するローカル・プラグインを削除
sounisi5011 Oct 24, 2019
c9104c9
コミット時にLessを整形する設定を削除
sounisi5011 Oct 24, 2019
d9b6995
yarn remove less @csstools/postcss-sass postcss-scss
sounisi5011 Oct 24, 2019
595e131
SCSSのlighten()関数とdarken()関数をビルトインモジュールに変更
sounisi5011 Oct 24, 2019
9292bd4
SCSSのmixinで名前空間を使用
sounisi5011 Oct 24, 2019
e4da1a7
Lessから受け継いだrepeat-content mixinを関数に変更
sounisi5011 Oct 24, 2019
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: 5 additions & 0 deletions .postcssrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
plugins:
autoprefixer:
remove: false
postcss-clean:
level: 2
23 changes: 11 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ const Metalsmith = require('metalsmith');
const assetsConvention = require('metalsmith-assets-convention');
const babel = require('metalsmith-babel');
const collections = require('metalsmith-collections');
const sass = require('metalsmith-dart-sass');
const directoryMetadata = require('metalsmith-directory-metadata');
const excerpts = require('metalsmith-excerpts');
const htmlValidator = require('metalsmith-html-validator');
const ignore = require('metalsmith-ignore');
const permalinks = require('metalsmith-permalinks');
const postcss = require('metalsmith-postcss');
const postcss = require('metalsmith-postcss2');
const {
compile: pugCompile,
render: pugRender,
Expand All @@ -28,7 +29,6 @@ const childPages = require('./src/plugins/child-pages');
const commentFrontmatter = require('./src/plugins/comment-matters');
const copyConvention = require('./src/plugins/copy-convention');
const downloadConvention = require('./src/plugins/download-convention');
const less = require('./src/plugins/less');
const mergePreloadDependencies = require('./src/plugins/merge-preload-dependencies');
const modernizr = require('./src/plugins/modernizr');
const mustache = require('./src/plugins/mustache');
Expand Down Expand Up @@ -164,19 +164,18 @@ Metalsmith(__dirname)
.use(
anotherSource('./src/styles')
.use(commentFrontmatter())
.use(less({ sourceMap: false }))
.use(
postcss({
// Source Mapのファイル名が<input css>になってしまうため無効化
map: false,
plugins: [
{ autoprefixer: { remove: false } },
{ 'postcss-clean': { level: 2 } },
],
}),
sass((_files, _metalsmith, defaultOptions) => ({
dependenciesKey: 'dependencies',
pattern: [...defaultOptions.pattern, '!**/_*/**'],
sassOptions: {
includePaths: ['node_modules'],
},
})),
)
.use(postcss())
.use(mergePreloadDependencies())
.use(ignore('**/*.less')),
.use(ignore('**/*.scss')),
)
.use(
anotherSource('./src/scripts')
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
},
"lint-staged": {
"!(package).json|*.{html,css,less,yaml,yml,toml}": [
"!(package).json|*.{html,css,scss,yaml,yml,toml}": [
"prettier --write",
"git add"
],
Expand Down Expand Up @@ -58,19 +58,19 @@
"image-size": "^0.7.4",
"is-url": "^1.2.4",
"keyv-file": "^0.1.13",
"less": "^3.9.0",
"metalsmith": "^2.3.0",
"metalsmith-assets-convention": "^2.1.1",
"metalsmith-babel": "^5.1.0",
"metalsmith-collections": "^0.9.0",
"metalsmith-dart-sass": "^1.0.1",
"metalsmith-directory-metadata": "^1.0.0",
"metalsmith-excerpts": "^1.2.0",
"metalsmith-html-validator": "^1.0.0",
"metalsmith-ignore": "^1.0.0",
"metalsmith-in-place": "^4.4.0",
"metalsmith-permalinks": "^2.2.0",
"metalsmith-plugin-kit": "^1.0.1",
"metalsmith-postcss": "^4.2.0",
"metalsmith-postcss2": "^1.0.0",
"metalsmith-pug-extra": "^1.0.1",
"mime": "^2.4.3",
"modernizr": "^3.7.1",
Expand Down
20 changes: 10 additions & 10 deletions src/plugins/comment-matters.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ function stripIndent(text) {

module.exports = opts => {
const options = {
'**/*.less': text => {
'**/*.pug': text => {
const match = /^\/\/-(?:\r\n?|\n)((?:(?:| +[^\r\n]*)(?:\r\n?|\n|$))+)/.exec(
text,
);
if (match) {
const commentText = match[1];
return stripIndent(commentText);
}
},
'**/*.{scss,less}': text => {
/*
* 複数行コメントを処理
*/
Expand All @@ -43,15 +52,6 @@ module.exports = opts => {
return stripIndent(commentText);
}
},
'**/*.pug': text => {
const match = /^\/\/-(?:\r\n?|\n)((?:(?:| +[^\r\n]*)(?:\r\n?|\n|$))+)/.exec(
text,
);
if (match) {
const commentText = match[1];
return stripIndent(commentText);
}
},
...opts,
};

Expand Down
113 changes: 0 additions & 113 deletions src/plugins/less.js

This file was deleted.

8 changes: 8 additions & 0 deletions src/styles/_fn.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* see https://stackoverflow.com/a/38713737/4907315 */
@function repeat($str, $count) {
$result: "";
@for $_ from 1 through $count {
$result: $result + $str;
}
@return $result;
}
5 changes: 5 additions & 0 deletions src/styles/_fontawesome/_base.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$fa-font-path: "/fontawesome";

@import "@fortawesome/fontawesome-free/scss/variables";
@import "@fortawesome/fontawesome-free/scss/mixins";
@import "@fortawesome/fontawesome-free/scss/core";
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
// - /fontawesome/fa-brands-400.woff2
// ---

@import "@fortawesome/fontawesome-free/less/fontawesome";
@import "@fortawesome/fontawesome-free/less/brands";
@fa-font-path: "/fontawesome";
@import "base";
@import "@fortawesome/fontawesome-free/scss/brands";
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
// - /fontawesome/fa-solid-900.woff2
// ---

@import "@fortawesome/fontawesome-free/less/fontawesome";
@import "@fortawesome/fontawesome-free/less/solid";
@fa-font-path: "/fontawesome";
@import "base";
@import "@fortawesome/fontawesome-free/scss/solid";
21 changes: 0 additions & 21 deletions src/styles/_mixins.less

This file was deleted.

15 changes: 15 additions & 0 deletions src/styles/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@mixin invisible-text {
font-size: 0;
line-height: 0;
}

@mixin pseudo-image-resize($image, $width: 1em, $height: 1em) {
/* see https://saruwakakun.com/html-css/reference/change-before-after */
content: "";
display: inline-block;
width: $width;
height: $height;
background-image: $image;
background-size: contain;
vertical-align: middle;
}
File renamed without changes.
2 changes: 0 additions & 2 deletions src/styles/default.less → src/styles/default.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import "_mixins";

html {
word-break: normal;
word-wrap: break-word;
Expand Down
6 changes: 3 additions & 3 deletions src/styles/footer.less → src/styles/footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ footer.page {
}

& > * {
@margin-v: 0.5em;
margin-top: @margin-v;
margin-bottom: @margin-v;
$margin-v: 0.5em;
margin-top: $margin-v;
margin-bottom: $margin-v;
}

small {
Expand Down
Loading