Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Last active October 23, 2020 12:01
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/df1fe65aab89bc6e9009f9448b545b90 to your computer and use it in GitHub Desktop.
Save flushpot1125/df1fe65aab89bc6e9009f9448b545b90 to your computer and use it in GitHub Desktop.
//参考:https://qiita.com/10mi8o/items/2477f2640291f0ce6687
/* 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 = {
entry: './src/index.js',//起点となるファイルのみを指定。src以下のファイルを個別に指定する必要はない
output: {
// バンドルしてmain.jsとして出力(これは実体として生成されないが、index.htmlなどで呼び出し記述が必要)
filename: 'main.js',
path: outputPath
},
// webpack-dev-serverを立ち上げた時のドキュメントルートを設定
//
devServer: {
contentBase: outputPath,
watchContentBase: true,//html,cssなどに変更があればブラウザリロードを自動実行
port: 3000
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment