This repository has been archived by the owner on Mar 13, 2020. It is now read-only.
forked from CSS-Electronics/cancloud
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.simple.js
128 lines (122 loc) · 2.92 KB
/
webpack.simple.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
117
118
119
120
121
122
123
124
125
126
127
128
/*
* CSS Cloud Storage browser.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const webpack = require("webpack");
const HtmlWebPackPlugin = require("html-webpack-plugin");
const WebpackShellPlugin = require("webpack-shell-plugin");
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const definePlugin = new webpack.DefinePlugin({
EDITOR: JSON.stringify({ offline: true })
});
const progressPlugin = new webpack.ProgressPlugin();
const shellPlugin = new WebpackShellPlugin({
onBuildStart: ['echo "Simple editor build starts"'],
onBuildEnd: ['echo "Simple editor build complete"'],
onBuildExit: ["node simple-editor.js"]
});
const htmlPlugin = new HtmlWebPackPlugin({
template: "./src/browser/index.html",
filename: "./index.html",
title: "Configuration Editor",
inject: false,
minify: true
});
module.exports = {
context: __dirname,
entry: [path.resolve(__dirname, "src/browser/simple.js")],
output: {
path: __dirname + "/simple",
filename: "bundle.js"
},
resolve: {
extensions: [".js", ".jsx", ".less"]
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: "babel-loader"
}
},
{
test: /\.less$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader"
},
{
loader: "less-loader"
}
]
},
{
test: /\.css$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader"
}
]
},
{
test: /\.(png|jpg|gif|svg|ico)$/,
use: [
{
loader: "url-loader",
options: {
limit: 800192
}
}
]
},
{
test: /\.svg/,
use: {
loader: "svg-url-loader",
options: {}
}
},
{
test: /\.(eot|woff|woff2|ttf|svg)/,
use: [
{
loader: "url-loader?limit=445000"
}
]
}
]
},
node: {
fs: "empty"
},
externals: [
nodeExternals({
whitelist: [/^((?!aws-sdk|react-chartjs-2).)*$/]
})
],
plugins: [progressPlugin, htmlPlugin, definePlugin, shellPlugin],
devServer: {
historyApiFallback: true,
contentBase: "./"
}
};