-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
89 lines (88 loc) · 2.99 KB
/
webpack.common.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
context: path.resolve(__dirname, './src'),
entry: { app: './app.js' },
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, "dist")
},
resolve: {
alias: {
App: path.resolve(__dirname, 'src'),
Map: path.resolve(__dirname, 'src/components/map'),
Sidebar: path.resolve(__dirname, 'src/components/sidebar'),
Data: path.resolve(__dirname, 'src/data/'),
Utilities: path.resolve(__dirname, 'src/utilities/'),
Stylesheets: path.resolve(__dirname, 'src/stylesheets/')
}
// modules: [path.resolve(__dirname, "./src"), "node_modules"]},
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].bundle.css',
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
new HtmlWebpackPlugin({
template: 'index.html'
})
],
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: process.env.NODE_ENV === 'development',
},
}
, 'css-loader'
],
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [{
loader: 'file-loader',
options: {
name:'img/[name].[ext]',
}
}]
},
{
test: /\.(ico)$/,
use: [{
loader: 'file-loader',
options: {
name:'[name].[ext]',
}
}]
},
{
test: /\.js$/,
enforce: "pre", // preload the eshint loader before transpile
exclude: [/node_modules/, /selectCtrl/],
use: [{
loader: "eslint-loader",
// options: { emitErrors: false, failOnHint: false, esversion: 6 }
options: { fix: true }
}]
},
{
test: /\.js$/,
exclude: [/node_modules/, /selectCtrl/],
use: [{ loader: 'babel-loader', options: { presets: ['@babel/preset-env'] } }],
},
// {
// test: /\.(woff2?|ttf|eot|jpe?g|png|gif|svg)$/,
// use: [{loader: 'file-loader?name=img/[name].[ext]'}]
// }
]
}
};