-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
61 lines (58 loc) · 1.86 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const path = require('path');
const Cleanwebpackplugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin')
module.exports = {
mode: 'development',
entry: {
'app': './app/src/index.js',
},
output: {
filename: "[name].[hash:5].js",
// publicPath:"js/", script src Prefix <script type="text/javascript" src="js/app.8aa23.js"></script></body>
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.css$/, //load css
use: [
{loader: 'style-loader' },
{loader: 'css-loader'}
]
},
{
test: /\.(png|jpg|gif)$/, //loade img
use: [
{
loader: 'url-loader',
options:{
limit:8192
}
}
]
},
{
// iconfont
test: /\.(woff|woff2|svg|eot|ttf)\??.*$/,
loader: 'url-loader',
},
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/,
}
]
},
devtool: 'cheap-module-eval-source-map',//prod env use cheap-module-source-map
/*devServer:{
contentBase:"app/public" //the index.html dir
},*/
plugins: [
new HtmlWebpackPlugin({template:'./app/public/index.html'}),
new Cleanwebpackplugin(['dist'])/*,
new CopyWebpackPlugin([
{ from: path.resolve(__dirname, 'app/'), to: path.resolve(__dirname, 'dist/'), ignore: [ path.resolve(__dirname, 'app/js/') ] }
])*/
]
};