0
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 1 year has passed since last update.

Laravel Mix の使いかた

Last updated at Posted at 2022-01-19

こちらのページと同様のことを行いました。
Stand-Alone Projects

簡易サーバーのインストール

sudo npm install http-server -g

Mix のインストール

mkdir my-app && cd my-app
npm init -y
npm install laravel-mix --save-dev

Mix の設定ファイルを作成

webpack.mix.js

let mix = require('laravel-mix');

mix.js('src/app.js', 'dist').setPublicPath('dist');

この時点でのフォルダーの構造

$ tree -L 1
.
├── node_modules
├── package.json
├── package-lock.json
└── webpack.mix.js

ソースファイルの作成

src/app.js
alert('こんにちは')

コンパイル

npx mix

success.png

HTML ファイルの作成

dist/index.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8" />
</head>
<body>
	<script src="app.js"></script>
</body>
</html>

dist で簡易サーバーの起動

$ http-server 
Starting up http-server, serving ./

http-server version: 14.1.0

http-server settings: 
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
  http://127.0.0.1:8080
  http://192.168.1.15:8080
Hit CTRL-C to stop the server

クライアントで
http://127.0.0.1:8080
にアクセス
laravel_mix.png

0
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
0
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?