forked from sparna-git/Sparnatural
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
116 lines (112 loc) · 2.83 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
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
const webpack = require("webpack");
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin'); // Require html-webpack-plugin plugin
const DashboardPlugin = require("webpack-dashboard/plugin");
const CopyPlugin = require('copy-webpack-plugin');
const WebpackBundleSizeAnalyzerPlugin = require('webpack-bundle-size-analyzer').WebpackBundleSizeAnalyzerPlugin;
let htmlPageNames = ['index-saved-query'];
let multipleHtmlPlugins = htmlPageNames.map(name => {
return new HtmlWebpackPlugin({
template: __dirname +`/src/${name}.html`, // relative path to the HTML files
filename: `${name}.html`, // output HTML files
inject: true,
chunks: [name] // respective JS files
})
});
module.exports = {
entry: [ "babel-polyfill", "./src/sparnatural.js" ],
output: {
path: path.resolve(__dirname, "./dist"),
filename: "sparnatural.js"
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: { loader: "babel-loader" }
},
{
test: /\.(sass|scss)$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
{
loader: "css-loader" // translates CSS into CommonJS
},
{
loader: "sass-loader" // compiles Sass to CSS
}
]
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
{
loader: "css-loader" // translates CSS into CommonJS
}
]
},
{
test: /\.(png|jp(e*)g|svg|gif)$/,
use: [{
loader: 'url-loader',
options: {
limit: 8000,
// Convert images < 8kb to base64 strings
// in case larger images are processed by file-loader
name: 'images/[hash]-[name].[ext]'
}
}]
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: __dirname + "/src/index.html",
inject: 'body'
}),
new HtmlWebpackPlugin({
filename: 'index-saved-query.html',
template: __dirname + "/src/index-saved-query.html",
inject: 'body'
}),
new MiniCssExtractPlugin({
filename: "sparnatural.css",
chunkFilename: "[id].css"
}),
new CopyPlugin([
{ from: 'static' }
]),
new DashboardPlugin(),
// so that JQuery is automatically inserted
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
})
/*
new webpack.ProvidePlugin({
datepicker: '@chenfengyuan/datepicke',
}),
*/
/*
new WebpackBundleSizeAnalyzerPlugin('./webpack-bundle-size-analyzer-report.txt')
*/
],
devServer: {
contentBase: path.resolve(__dirname, "./dist"),
historyApiFallback: true,
inline: true,
open: true,
hot: true
},
/* terrible, generates huge output files */
/* devtool: "eval-source-map" */
devtool: "source-map"
}