-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: refactor example to support open browser auto and hot reload * refactor:refactor example webpack.dev.conf.js
- Loading branch information
1 parent
2273a39
commit 3012bc6
Showing
13 changed files
with
8,051 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const path = require('path') | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const webpack = require('webpack') | ||
|
||
const HtmlWebpackPluginConfig = { | ||
filename: 'index.html', | ||
template: './template/index.html', | ||
inject:'body', | ||
} | ||
|
||
module.exports = { | ||
context: path.resolve(__dirname,'../src'), | ||
entry: './main', | ||
output:{ | ||
path:path.resolve(__dirname,'../dist'), | ||
filename: './[hash]app.js', | ||
hashDigestLength: 8 | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: [ 'style-loader', 'css-loader' ] | ||
}, | ||
{ | ||
test: /\.(eot|woff|woff2)$/, | ||
loader: "file-loader" | ||
}, | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
} | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
new HtmlWebpackPlugin(HtmlWebpackPluginConfig), | ||
new webpack.ProvidePlugin({ | ||
$: 'jquery', | ||
jQuery: 'jquery', | ||
'window.jQuery': 'jquery', | ||
Popper: ['popper.js', 'default'] | ||
}) | ||
], | ||
devServer: { | ||
contentBase: path.resolve(__dirname, "../dist"), | ||
port: 3000, | ||
open: true, // open browser auto | ||
index:'index.html', // like HtmlWebpackPlugin | ||
inline:true, // default:true | ||
hot:false, | ||
compress:true // compress | ||
} | ||
} |
Oops, something went wrong.