const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
//壓縮級別
devtool : 'eval-source-map',
//“__dirname”是node.js中的一個全局變量,它指向當前執行腳本所在的目錄。
entry: __dirname + "/app/main.js",
//打包輸出路徑
output: {
path: __dirname + "/build",//打包後的文件存放的地方
filename: "bundle.js"//打包後輸出文件的文件名
},
//webpack服務器
devServer:{
//工程路徑
contentBase : "./public",
historyApiFallback: true,//不跳轉
inline :true //實時刷新
},
module: {
rules: [
{
test: /(\.jsx|\.js)$/,
use: {
loader: "babel-loader"
},
exclude: /node_modules/
},
{
test: /\.css$/,
use: [
{
loader: "style-loader"
}, {
loader: "css-loader",
options: {
modules: true
}
}, {
loader: "postcss-loader"
}
]
}
]
},
plugins: [
new webpack.BannerPlugin('版權所有,翻版必究'),
new HtmlWebpackPlugin({
template: __dirname + "/app/index.tmpl.html" //new 一個這個插件的實例,並傳入相關的參數
}),
new webpack.HotModuleReplacementPlugin()//熱加載插件
],
};
webpack配置文件
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.