LoginSignup
1
0

More than 3 years have passed since last update.

ParcelでPug + Stylus + TypeScriptの環境構築

Posted at

WebPack, Gulp, WebPack+Gulp, Preprosなど色々な環境構築で比較した結果Parcelにたどりつきました。

ソースコード

とりあえずクローンしてyarnしたあとyarn devで動きます。

Install

インストールするのもは1つだけです。

yarn global add parcel-bundler

Settings

基本的には、package.json書くだけです。

package.json
{
  "scripts": {
    "dev": "parcel \"pug/**/!(_)*.pug\"",
    "watch": "parcel watch \"pug/**/!(_)*.pug\"",
    "build": "parcel build \"pug/**/!(_)*.pug\""
  },
}

\"使っている理由は以下の記事に書いてます。
- Parcelを使う時にハマったpackage.jsonのscripts

Autoprefixerの設定

postcss.config.js
module.exports = {
  plugins: [require('autoprefixer')({ grid: true })],
}

TSの設定

初心者なんでわからないんでどっかで見つけたtsconfig.jsonも入れときます。

tsconfig.json
{
  "compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "outDir": "lib",
    "typeRoots": ["node_modules/@typings"]
  },
  "exclude": ["node_modules"]
}

気になるところ

ブラウザでアクセスした時にhttp://localhost:1234なんですがhttp://localhost:1234/index.htmlのようにindex.htmlまで入れないとindexのファイル表示できないです。

誰か知っていれば教えていただきたいです!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0