forked from code-troopers/code-troopers.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.conf.dev.js
More file actions
80 lines (79 loc) · 2.17 KB
/
webpack.conf.dev.js
File metadata and controls
80 lines (79 loc) · 2.17 KB
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
import webpack from 'webpack';
import glob from 'glob';
import path from 'path';
import postCSS from './config/postcss';
import cssNano from './config/cssnano';
export default function() {
const optimizePlugins = [
new webpack.HotModuleReplacementPlugin()
];
const cssLoaders = [
{ loader: 'css-loader', options: Object.assign({ minimize: false, sourceMap: true }, cssNano) },
{ loader: 'postcss-loader', options: Object.assign({ sourceMap: true }, postCSS) },
{ loader: 'resolve-url-loader', options: { sourceMap: true } },
{ loader: 'sass-loader', options: { sourceMap: true } }
];
cssLoaders.unshift('style-loader');
return {
devtool: 'source-map',
module: {
rules: [
{
test: /\.((jpe?g)|(png)|(svg)|(gif)|(mp4)|(webm))(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader?name=[path][name].[ext]'
},
{
test: /\.((eot)|(woff)|(woff2)|(ttf))(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader?name=[name].[hash:4].[ext]'
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.js?$/,
exclude: /node_modules\/(?!(dom7|swiper)\/).*/,
loaders: [
'babel-loader'
]
},
{
test: /\.(scss|sass)?$/,
use: cssLoaders
}
]
},
context: path.join(__dirname, 'src'),
entry: function() { //eslint-disable-line object-shorthand
const hot = ['webpack-hot-middleware/client?reload=true'];
const js = ['./js/app.js'];
const img = glob.sync('./img/**/*', {
absolute: true,
cwd: this.context,
matchBase: true,
nodir: true,
nosort: true
});
return {
main: [...hot, ...js, ...img],
blog: ['./js/blog.js']
};
},
output: {
path: path.join(__dirname, './dist'),
publicPath: '/'
},
plugins: [
new webpack.ProvidePlugin({
fetch: 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch'
}),
...optimizePlugins
],
resolve: {
modules: [
path.resolve('src'),
'node_modules'
]
}
};
}