<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja_JP"><generator uri="https://jekyllrb.com/" version="3.6.2">Jekyll</generator><link href="https://chocolateorange.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://chocolateorange.github.io/" rel="alternate" type="text/html" hreflang="ja_JP" /><updated>2017-11-09T00:41:09+09:00</updated><id>https://chocolateorange.github.io/</id><title type="html">chocolateorange.github.io</title><subtitle>website of chocolateorange</subtitle><author><name>sasaplus1</name></author><entry><title type="html">03</title><link href="https://chocolateorange.github.io/2017/11/08/03/" rel="alternate" type="text/html" title="03" /><published>2017-11-08T00:00:00+09:00</published><updated>2017-11-08T00:00:00+09:00</updated><id>https://chocolateorange.github.io/2017/11/08/03</id><content type="html" xml:base="https://chocolateorange.github.io/2017/11/08/03/">&lt;p&gt;&lt;a href=&quot;http://sass-compatibility.github.io/&quot;&gt;Sass Compatibility&lt;/a&gt;関連のリンクについて。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://sass-compatibility.github.io/&quot;&gt;Sass Compatibility&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/sass-compatibility&quot;&gt;GitHub Organization&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>sasaplus1</name></author><summary type="html">Sass Compatibility関連のリンクについて。</summary></entry><entry><title type="html">02</title><link href="https://chocolateorange.github.io/2017/11/08/02/" rel="alternate" type="text/html" title="02" /><published>2017-11-08T00:00:00+09:00</published><updated>2017-11-08T00:00:00+09:00</updated><id>https://chocolateorange.github.io/2017/11/08/02</id><content type="html" xml:base="https://chocolateorange.github.io/2017/11/08/02/">&lt;p&gt;npmからインストールできる&lt;code class=&quot;highlighter-rouge&quot;&gt;sass&lt;/code&gt;モジュールについて。&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;npm install sass&lt;/code&gt;でインストールされるモジュールがいつの間にか&lt;code class=&quot;highlighter-rouge&quot;&gt;dart-sass&lt;/code&gt;になっていた。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.npmjs.com/package/sass&quot;&gt;sass&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.npmjs.com/package/dart-sass&quot;&gt;dart-sass&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;dart-sass&lt;/code&gt;は名前からもわかるようにDartで書かれており、JavaScriptにコンパイルされたコードがモジュールとしてインストールされる。&lt;/p&gt;

&lt;p&gt;実行ファイルもインストールされるので、コマンドラインから&lt;code class=&quot;highlighter-rouge&quot;&gt;sass&lt;/code&gt;コマンドとして使用できる。&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; ./node_modules/.bin/sass &lt;span class=&quot;nt&quot;&gt;--help&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Compile Sass to CSS.

&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;Usage: dart-sass &amp;lt;input&amp;gt;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;
    --[no-]stdin    Read the stylesheet from stdin.
-s, --style         Output style.
                    [expanded (default)]

-c, --[no-]color    Whether to emit terminal colors.
    --[no-]trace    Print full Dart stack traces for exceptions.
-h, --help          Print this usage information.
    --version       Print the version of Dart Sass.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>sasaplus1</name></author><summary type="html">npmからインストールできるsassモジュールについて。</summary></entry><entry><title type="html">01</title><link href="https://chocolateorange.github.io/2017/11/08/01/" rel="alternate" type="text/html" title="01" /><published>2017-11-08T00:00:00+09:00</published><updated>2017-11-08T00:00:00+09:00</updated><id>https://chocolateorange.github.io/2017/11/08/01</id><content type="html" xml:base="https://chocolateorange.github.io/2017/11/08/01/">&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;npm&lt;/code&gt;コマンドから取得できるパスについて。&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; npm bin
&lt;span class=&quot;go&quot;&gt;/path/to/repos/node_modules/.bin
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; npm root
&lt;span class=&quot;go&quot;&gt;/path/to/repos/node_modules
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; npm prefix
&lt;span class=&quot;go&quot;&gt;/path/to/repos
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;いずれのサブコマンドも&lt;code class=&quot;highlighter-rouge&quot;&gt;-g&lt;/code&gt;オプションを付けることによってグローバル領域のパスを取得できる。&lt;/p&gt;</content><author><name>sasaplus1</name></author><summary type="html">npmコマンドから取得できるパスについて。</summary></entry><entry><title type="html">Travis-CIでコンテナベースの環境にパッケージを追加する</title><link href="https://chocolateorange.github.io/2017/07/13/02/" rel="alternate" type="text/html" title="Travis-CIでコンテナベースの環境にパッケージを追加する" /><published>2017-07-13T00:00:00+09:00</published><updated>2017-07-13T00:00:00+09:00</updated><id>https://chocolateorange.github.io/2017/07/13/02</id><content type="html" xml:base="https://chocolateorange.github.io/2017/07/13/02/">&lt;p&gt;Travis-CIでは&lt;code class=&quot;highlighter-rouge&quot;&gt;sudo: false&lt;/code&gt;とするとコンテナベースの環境が使用され、動作が高速になるが通常の方法によるパッケージの追加ができない。&lt;/p&gt;

&lt;p&gt;APTアドオンを使用することによって、コンテナベースの環境でもパッケージを追加できる。&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://docs.travis-ci.com/user/installing-dependencies/#Installing-Packages-with-the-APT-Addon&quot;&gt;Installing Packages with the APT Addon&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ホワイトリストは以下のリポジトリから確認できる。&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/travis-ci/apt-source-whitelist&quot;&gt;https://github.com/travis-ci/apt-source-whitelist&lt;/a&gt;&lt;/p&gt;</content><author><name>sasaplus1</name></author><category term="ci" /><category term="travis" /><summary type="html">Travis-CIではsudo: falseとするとコンテナベースの環境が使用され、動作が高速になるが通常の方法によるパッケージの追加ができない。</summary></entry><entry><title type="html">GoogleアラートとはてなアンテナをRSSフィードで読む</title><link href="https://chocolateorange.github.io/2017/07/13/01/" rel="alternate" type="text/html" title="GoogleアラートとはてなアンテナをRSSフィードで読む" /><published>2017-07-13T00:00:00+09:00</published><updated>2017-07-13T00:00:00+09:00</updated><id>https://chocolateorange.github.io/2017/07/13/01</id><content type="html" xml:base="https://chocolateorange.github.io/2017/07/13/01/">&lt;p&gt;Googleアラートとはてなアンテナに登録した情報をRSSフィードで読む方法について。&lt;/p&gt;

&lt;h2 id=&quot;googleアラート&quot;&gt;Googleアラート&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://www.google.com/alerts&quot;&gt;Googleアラート&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;アラートを作成する際にオプションを表示し、配信先を「RSS フィード」に選択してから作成するとフィードのアイコンが表示されるので、それをRSSフィードに登録する。&lt;/p&gt;

&lt;h2 id=&quot;はてなアンテナ&quot;&gt;はてなアンテナ&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://a.hatena.ne.jp&quot;&gt;はてなアンテナ&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;URLの末尾に&lt;code class=&quot;highlighter-rouge&quot;&gt;/rss&lt;/code&gt;を付加すると、RSSが配信されているので、それをRSSフィードに登録する。&lt;/p&gt;

&lt;p&gt;以下に詳しく記載してある。&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://hatenaantenna.g.hatena.ne.jp/keyword/RSS%28RDF%20Site%20Summary%29%E3%81%AE%E9%85%8D%E5%B8%83%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6&quot;&gt;RSS(RDF Site Summary)の配布について&lt;/a&gt;&lt;/p&gt;</content><author><name>sasaplus1</name></author><category term="alert" /><category term="antenna" /><category term="google" /><category term="hatena" /><summary type="html">Googleアラートとはてなアンテナに登録した情報をRSSフィードで読む方法について。</summary></entry><entry><title type="html">dアカウントのロックを解除する</title><link href="https://chocolateorange.github.io/2017/07/12/01/" rel="alternate" type="text/html" title="dアカウントのロックを解除する" /><published>2017-07-12T00:00:00+09:00</published><updated>2017-07-12T00:00:00+09:00</updated><id>https://chocolateorange.github.io/2017/07/12/01</id><content type="html" xml:base="https://chocolateorange.github.io/2017/07/12/01/">&lt;p&gt;SPモードの契約をしていないドコモの回線でdアカウントがロックされた場合、アカウントの再発行をし既存のアカウントを上書きすることでロックを解除するのと同等のことができる。&lt;/p&gt;

&lt;p&gt;回線の契約やdアニメストアなどの契約は上書きされるアカウントのものを引き継げる。（引き継げた）&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;アカウントの再発行をする手順は以下の通り。&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://id.smt.docomo.ne.jp/src/utility/pc/faq1.html#p04&quot;&gt;「ID/パスワード」を何度か誤って入力したら「ID/パスワードがロックされているため、ログインできません。 ロック解除の手続きを行ってください。」というメッセージが表示され、ログインできなくなりましたが、どうしたらよいですか？&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;自分は上記のページの「SMSが受信できる端末をご利用のお客様」に該当したので、以下を試した。&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;ドコモのお客様で、SMS(ショートメール)を受信できる端末をご利用の場合、パソコン等からdアカウントの再発行をすることでロック解除ができます。再発行をしても契約内容や設定内容は変更されません。
再発行は、「dアカウントを発行する」で開く画面の「ドコモの回線をお持ちの方」を選択し、画面の表示に従ってお手続きください。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;アカウントの再発行をする際、試しに、と思いロックされた既存のアカウントと同じアカウント名を使用したところ、同じアカウント名で再発行をすることができた。&lt;/p&gt;

&lt;p&gt;上書きしたアカウントはdアニメストアに正常にログインでき、視聴履歴などもそのまま残っていた。「料金の確認・お支払い」のページも開くことができ、契約している回線の情報が表示された。&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;経緯としては、料金の確認をしようとdアカウントにログインしようとして、何度もログインに失敗してしまいロックされてしまった。仕方がないので以下のページを読むことに。&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://id.smt.docomo.ne.jp/src/utility/idpw_forget.html&quot;&gt;ID/パスワードをお忘れの方・ロックがかかってしまった方&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;上記のページに記載してある方法を試していたのだけど、埒が明かず、仕方なくドコモショップに行って確認したところ、以下の方法を紹介された。&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;SPモードを一度契約してロックを解除する&lt;/li&gt;
  &lt;li&gt;新しくアカウントを作りそのアカウントを電話番号と紐づける&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;今回の再発行は2.に近いが、複数のアカウントが存在することになる、と言っていたので今回の再発行とは異なる。また、使わなくなるとはいえログインできないアカウントが残されたままになるのは避けたかった。&lt;/p&gt;

&lt;p&gt;なので1.を試す他ないと思っていたが、しぶとく調べていたところ&lt;a href=&quot;http://id.smt.docomo.ne.jp/src/utility/pc/faq1.html#p04&quot;&gt;「ID/パスワード」を何度か誤って入力したら「ID/パスワードがロックされているため、ログインできません。 ロック解除の手続きを行ってください。」というメッセージが表示され、ログインできなくなりましたが、どうしたらよいですか？&lt;/a&gt;を見つけることができ、試してみたところ上手くいった。&lt;/p&gt;</content><author><name>sasaplus1</name></author><category term="docomo" /><summary type="html">SPモードの契約をしていないドコモの回線でdアカウントがロックされた場合、アカウントの再発行をし既存のアカウントを上書きすることでロックを解除するのと同等のことができる。</summary></entry><entry><title type="html">formの中にある要素にname属性の値でアクセスする</title><link href="https://chocolateorange.github.io/2017/06/28/01/" rel="alternate" type="text/html" title="formの中にある要素にname属性の値でアクセスする" /><published>2017-06-28T00:00:00+09:00</published><updated>2017-06-28T00:00:00+09:00</updated><id>https://chocolateorange.github.io/2017/06/28/01</id><content type="html" xml:base="https://chocolateorange.github.io/2017/06/28/01/">&lt;p&gt;formの中にある要素を取得する方法をよく忘れるのでメモしておく。&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;form1&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text1&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;上記のようにマークアップされていた場合、&lt;code class=&quot;highlighter-rouge&quot;&gt;form&lt;/code&gt;要素を取得するには以下のコードでアクセスできる。&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;form1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;input&lt;/code&gt;要素を取得するには以下のコードでアクセスできる。&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;form1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;text1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;ドキュメント内のすべての&lt;code class=&quot;highlighter-rouge&quot;&gt;form&lt;/code&gt;要素を取得したければ、以下のコードでアクセスできる。&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;forms&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>sasaplus1</name></author><category term="javascript" /><category term="html" /><summary type="html">formの中にある要素を取得する方法をよく忘れるのでメモしておく。</summary></entry><entry><title type="html">UglifyJSで文字列をエスケープシーケンスに変換する</title><link href="https://chocolateorange.github.io/2017/06/16/01/" rel="alternate" type="text/html" title="UglifyJSで文字列をエスケープシーケンスに変換する" /><published>2017-06-16T00:00:00+09:00</published><updated>2017-06-16T00:00:00+09:00</updated><id>https://chocolateorange.github.io/2017/06/16/01</id><content type="html" xml:base="https://chocolateorange.github.io/2017/06/16/01/">&lt;p&gt;HTMLがShift_JISで配信されている環境で、JavaScriptにマルチバイトの文字を書いてUTF-8で保存し、ブラウザでアラートを表示したら文字化けしてしまった。&lt;/p&gt;

&lt;p&gt;素直にスクリプトをShift_JISで保存し直せばよかったのだろうが、UTF-8で保存したかったので文字列をエスケープシーケンスへ変換することにした。&lt;/p&gt;

&lt;p&gt;調べてみると、UglifyJSにはエスケープシーケンスに変換するオプションがあるようで、以下のIssueのコメントのようにすると変換できる。&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mishoo/UglifyJS2/issues/490#issuecomment-53410397&quot;&gt;https://github.com/mishoo/UglifyJS2/issues/490#issuecomment-53410397&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;cli&quot;&gt;CLI&lt;/h2&gt;

&lt;p&gt;CLIから実行する場合は以下のようにオプションを指定する。&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; uglifyjs index.js &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;beautify&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,ascii_only&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;   
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;標準入力からスクリプトを与えると以下のような出力になった。&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'alert(&quot;マルチバイト&quot;)'&lt;/span&gt; | uglifyjs &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;beautify&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;,ascii_only&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;alert(&quot;\u30de\u30eb\u30c1\u30d0\u30a4\u30c8&quot;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;webpack&quot;&gt;webpack&lt;/h2&gt;

&lt;p&gt;webpackの場合は&lt;a href=&quot;https://github.com/webpack-contrib/uglifyjs-webpack-plugin&quot;&gt;UglifyJS Webpack Plugin&lt;/a&gt;を使用するので、以下のようにオプションを指定する。&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;webpack&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'webpack'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;plugins&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;webpack&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;optimize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;UglifyJSPlugin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;ascii_only&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}),&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>sasaplus1</name></author><category term="javascript" /><category term="uglifyjs" /><category term="webpack" /><summary type="html">HTMLがShift_JISで配信されている環境で、JavaScriptにマルチバイトの文字を書いてUTF-8で保存し、ブラウザでアラートを表示したら文字化けしてしまった。</summary></entry><entry><title type="html">ツールの設定をpackage.jsonに書く</title><link href="https://chocolateorange.github.io/2017/05/03/01/" rel="alternate" type="text/html" title="ツールの設定をpackage.jsonに書く" /><published>2017-05-03T00:00:00+09:00</published><updated>2017-05-03T00:00:00+09:00</updated><id>https://chocolateorange.github.io/2017/05/03/01</id><content type="html" xml:base="https://chocolateorange.github.io/2017/05/03/01/">&lt;p&gt;昨今のJavaScript開発では&lt;a href=&quot;https://babeljs.io/&quot;&gt;Babel&lt;/a&gt;や&lt;a href=&quot;http://eslint.org/&quot;&gt;ESLint&lt;/a&gt;などのツールがよく使われるが、これらのツールを複数使用すると&lt;code class=&quot;highlighter-rouge&quot;&gt;.babelrc&lt;/code&gt;や&lt;code class=&quot;highlighter-rouge&quot;&gt;.eslintrc&lt;/code&gt;などの設定ファイルがリポジトリのルートディレクトリに複数存在することとなる。&lt;/p&gt;

&lt;p&gt;ツールの数が増えると設定ファイルも増えるので、管理するファイルが増える。そこで、いくつかのツールは&lt;code class=&quot;highlighter-rouge&quot;&gt;package.json&lt;/code&gt;に設定を記述できるので、これを利用すると個別の設定ファイルを作成せずに済む。&lt;/p&gt;

&lt;h2 id=&quot;babel&quot;&gt;Babel&lt;/h2&gt;

&lt;p&gt;Babelは&lt;code class=&quot;highlighter-rouge&quot;&gt;babel&lt;/code&gt;という名前でフィールドを作成すると読み込まれる。&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;babel&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;presets&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;es2015&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;参考ページ：&lt;a href=&quot;https://babeljs.io/docs/usage/babelrc/#use-via-package-json&quot;&gt;Use via package.json&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;eslint&quot;&gt;ESLint&lt;/h2&gt;

&lt;p&gt;ESLintは&lt;code class=&quot;highlighter-rouge&quot;&gt;eslintConfig&lt;/code&gt;という名前でフィールドを作成すると読み込まれる。&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;eslintConfig&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;extends&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;eslint:recommended&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;参考ページ：&lt;a href=&quot;http://eslint.org/docs/user-guide/configuring&quot;&gt;Configuring ESLint&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;postcss-cli&quot;&gt;PostCSS CLI&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/postcss/postcss-cli&quot;&gt;PostCSS CLI&lt;/a&gt;は&lt;code class=&quot;highlighter-rouge&quot;&gt;postcss&lt;/code&gt;という名前でフィールドを作成すると読み込まれる。&lt;/p&gt;

&lt;p&gt;PostCSS CLIが対応している（正確にはPostCSS CLIが使用している&lt;a href=&quot;https://github.com/michael-ciniawsky/postcss-load-config&quot;&gt;postcss-load-config&lt;/a&gt;が）のであって、&lt;a href=&quot;http://postcss.org/&quot;&gt;PostCSS&lt;/a&gt;本体は対応していないようだ。&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;postcss&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;from&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/path/to/src.css&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;to&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/path/to/dest.css&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;参考ページ：&lt;a href=&quot;https://github.com/michael-ciniawsky/postcss-load-config#packagejson&quot;&gt;postcss-load-config#packagejson&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;stylelint&quot;&gt;stylelint&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://stylelint.io/&quot;&gt;stylelint&lt;/a&gt;は&lt;code class=&quot;highlighter-rouge&quot;&gt;stylelint&lt;/code&gt;という名前でフィールドを作成すると読み込まれる。&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;stylelint&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;extends&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;stylelint-config-standard&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;参考ページ：&lt;a href=&quot;https://stylelint.io/user-guide/configuration/#loading-the-configuration-object&quot;&gt;Loading the configuration object&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;browserslist&quot;&gt;browserslist&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/ai/browserslist&quot;&gt;browserslist&lt;/a&gt;は&lt;code class=&quot;highlighter-rouge&quot;&gt;browserslist&lt;/code&gt;という名前でフィールドを作成すると読み込まれる。&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/postcss/autoprefixer&quot;&gt;Autoprefixer&lt;/a&gt;や&lt;a href=&quot;https://github.com/babel/babel-preset-env&quot;&gt;babel-preset-env&lt;/a&gt;などのモジュールがこれを使用している。&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;browserslist&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;last 2 Chrome versions&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;last 2 Firefox versions&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;参考ページ：&lt;a href=&quot;https://github.com/ai/browserslist#browserslist&quot;&gt;browserslist#browserslist&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;browserslist&lt;/code&gt;フィールドと&lt;code class=&quot;highlighter-rouge&quot;&gt;babel-preset-env&lt;/code&gt;の設定を含んだ&lt;code class=&quot;highlighter-rouge&quot;&gt;babel&lt;/code&gt;フィールドはどちらが優先されるかは不明。&lt;/p&gt;

&lt;h2 id=&quot;設定を読み込むモジュール&quot;&gt;設定を読み込むモジュール&lt;/h2&gt;

&lt;p&gt;設定を読み込むモジュールには以下のようなものがある。上記のツールの多くはcosmiconfigを使用している。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/davidtheclark/cosmiconfig&quot;&gt;davidtheclark/cosmiconfig&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/azu/rc-config-loader&quot;&gt;azu/rc-config-loader&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://github.com/textlint/textlint&quot;&gt;textlint&lt;/a&gt;が使用している&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/MoOx/rc-loader&quot;&gt;MoOx/rc-loader&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;メンテナンスされていない&lt;/li&gt;
      &lt;li&gt;cosmiconfigに代わられた&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;</content><author><name>sasaplus1</name></author><category term="babel" /><category term="browserslist" /><category term="eslint" /><category term="postcss" /><category term="stylelint" /><summary type="html">昨今のJavaScript開発ではBabelやESLintなどのツールがよく使われるが、これらのツールを複数使用すると.babelrcや.eslintrcなどの設定ファイルがリポジトリのルートディレクトリに複数存在することとなる。</summary></entry><entry><title type="html">fs.existsSyncが非推奨ではなくなっていた</title><link href="https://chocolateorange.github.io/2017/03/27/01/" rel="alternate" type="text/html" title="fs.existsSyncが非推奨ではなくなっていた" /><published>2017-03-27T00:00:00+09:00</published><updated>2017-03-27T00:00:00+09:00</updated><id>https://chocolateorange.github.io/2017/03/27/01</id><content type="html" xml:base="https://chocolateorange.github.io/2017/03/27/01/">&lt;p&gt;node.jsのドキュメントを読んでいた時に&lt;code class=&quot;highlighter-rouge&quot;&gt;fs.existsSync()&lt;/code&gt;が非推奨ではなくなっていたことにふと気がついた。&lt;/p&gt;

&lt;p&gt;調べてみるとver.6.xから非推奨ではなくなっている。&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;バージョン&lt;/th&gt;
      &lt;th&gt;記述&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://nodejs.org/docs/latest-v0.10.x/api/fs.html#fs_fs_existssync_path&quot;&gt;0.10.x&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;特になし&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://nodejs.org/docs/latest-v0.12.x/api/fs.html#fs_fs_existssync_path&quot;&gt;0.12.x&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;非推奨になります&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://nodejs.org/docs/latest-v4.x/api/fs.html#fs_fs_existssync_path&quot;&gt;4.x&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;非推奨&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://nodejs.org/docs/latest-v5.x/api/fs.html#fs_fs_existssync_path&quot;&gt;5.x&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;非推奨&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://nodejs.org/dist/latest-v6.x/docs/api/fs.html#fs_fs_existssync_path&quot;&gt;6.x&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;非推奨&lt;strong&gt;ではありません&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://nodejs.org/dist/latest-v7.x/docs/api/fs.html#fs_fs_existssync_path&quot;&gt;7.x&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;非推奨&lt;strong&gt;ではありません&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;調べてみると、&lt;a href=&quot;https://github.com/nodejs/node/issues/1592#issuecomment-251770788&quot;&gt;issues/1592&lt;/a&gt;や&lt;a href=&quot;https://github.com/nodejs/node/commit/7b5ffa46fe4d2868c1662694da06eb55ec744bde&quot;&gt;commit/7b5ffa46fe4d2868c1662694da06eb55ec744bde&lt;/a&gt;で非推奨が取り消されているのを確認できた。&lt;/p&gt;

&lt;p&gt;非同期の&lt;code class=&quot;highlighter-rouge&quot;&gt;fs.exists()&lt;/code&gt;は変わらず非推奨になっている。&lt;/p&gt;</content><author><name>sasaplus1</name></author><category term="node.js" /><summary type="html">node.jsのドキュメントを読んでいた時にfs.existsSync()が非推奨ではなくなっていたことにふと気がついた。</summary></entry></feed>