-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.common.js
116 lines (102 loc) · 3.15 KB
/
webpack.config.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* Copyright 2018 interactive instruments GmbH
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
const resolve = require('path').resolve;
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = function(env) {
/*const extractSass = new ExtractTextPlugin({
filename: "[name].[contenthash].css",
disable: env !== "production"
});*/
const devMode = env !== "production"
return {
context: resolve(__dirname, 'src'),
entry: [
'./index.jsx'
],
output: {
filename: '[name].js',
path: resolve(__dirname, 'build')
},
devtool: 'eval',
watchOptions: {
ignored: /node_modules/,
},
resolve: {
extensions: [".js", ".jsx", ".json", ".scss"]
},
module: {
rules: [
{
test: /\.jsx?$/,
use: [{
loader: 'babel-loader',
}],
exclude: /node_modules(?!(\/|[\\]+)xtraplatform)/
},
{
test: /\.scss$/,
/*use: extractSass.extract({
use: [{
loader: "css-loader"
}, {
loader: "sass-loader",
options: {
includePaths: ["node_modules"]
}
}],
fallback: "style-loader"
})*/
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
{
loader: "sass-loader",
options: {
includePaths: ["node_modules"]
}
}
]
}
],
},
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
test: /[\\/](node_modules|vendor)[\\/]/
}
}
}
},
plugins: [
/*new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function(module) {
return module.context && (module.context.indexOf('node_modules') !== -1 || module.context.indexOf('vendor') !== -1);
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest'
}),*/
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: devMode ? '[name].css' : '[name].[hash].css',
chunkFilename: devMode ? '[id].css' : '[id].[hash].css',
}),
new HtmlWebpackPlugin({
title: 'XtraPlatform Manager',
//favicon: 'assets/img/favicon.png',
template: resolve(__dirname, 'src/index.html')
}),
//extractSass
],
}
};