Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Last active September 16, 2023 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/85423581c4de80c770ed208d88407722 to your computer and use it in GitHub Desktop.
Save flushpot1125/85423581c4de80c770ed208d88407722 to your computer and use it in GitHub Desktop.
//参考:https://qiita.com/10mi8o/items/2477f2640291f0ce6687
//参考:https://qiita.com/chocomint_t/items/4bc57945bce081922582
/* pathモジュールを使ってwebページとして出力するパスを指定する。
"path.resolveは、引数をつなげて絶対パスに変換する"
"__dirname"は、実行集のソースコードが格納されているディレクトリパス
参考:https://gist.github.com/uupaa/da42698d6b2d2cbb3cca
*/
const path = require('path');
//const outputPath = path.resolve(__dirname, 'dist');
const outputPath = path.resolve(__dirname, './');//distではなくプロジェクトのトップに変更
module.exports = {
mode: 'development',
entry: './src/index.js',//起点となるファイルのみを指定。src以下のファイルを個別に指定する必要はない
output: {
// バンドルしてmain.jsとして出力(これは実体として生成されないが、index.htmlなどで呼び出し記述が必要)
filename: 'main.js',
path: outputPath
},
// webpack-dev-serverを立ち上げた時のドキュメントルートを設定
//
devServer: {
static:{
directory: outputPath,
watch:true//html,cssなどに変更があればブラウザリロードを自動実行
},
port: 8080
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment