1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ministaのwebpack設定が上書きできるようになったからオレオレwebpack公開する

Last updated at Posted at 2021-06-29

ReactからHTMLを生成する静的サイトジェネレーターのministaを試してみました。
Zennでの紹介ページ

素晴らしいnpmを開発されたクラクさんはこちら(@Qrac_JP)

[追記]alias追加しました!

事前準備

bash
# 追加
yarn add import-glob-loader --dev

webpack追加

webpack.config.js
const webpack = require('webpack')

const webpackConfig = {
  module: {
    rules: [
      {
        test: /\.(sass|scss)$/,
        use: ['import-glob-loader']
      }
    ],
  },
  // import React from 'react'書かなくていい!
  plugins: [
    new webpack.ProvidePlugin({
      React: 'react'
    }),
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
}

module.exports = webpackConfig

これでsassのまとめてインポートができます。やったね!

index.scss
/* ~ 略 ~ */

@import "./foundations/**/*";
@import "./layouts/**/*";
@import "./objects/**/*";

JSXの相対path地獄もこれで改善

import AppLayout from "../../components/app-layout"

import AppLayout from "@/components/app-layout"

ちなみにstyled-componentsを採用しようと思ったんですが、ビルドうまくいかなかったです。。gununu

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?