forked from smrsan76/imrc-datetime-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
101 lines (99 loc) · 2.53 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { argv } = require("yargs");
const webpack = require("webpack");
const Fiber = require("fibers");
// import HtmlWebpackPlugin from "html-webpack-plugin";
// import MiniCssExtractPlugin from "mini-css-extract-plugin";
const env = argv.env;
const isDevelopment = env === "development";
const isProduction = env === "production";
const libPath = path.resolve(__dirname, "./lib");
module.exports = {
mode: 'development',
devtool: isDevelopment ? "source-map" : "",
devServer: {
hot: true,
noInfo: true,
compress: true,
historyApiFallback: true,
https: isProduction,
open: true
// contentBase: path.resolve(__dirname, "js.org")
},
entry: {
index: [path.resolve(__dirname, "./docs/index.jsx")]
},
output: {
publicPath: isDevelopment ? "/" : "./",
// path: path.resolve(__dirname, "./js.org"),
filename: `[name].js`,
chunkFilename: `${isDevelopment ? "[id]" : "[chunkhash]"}.js`
},
module: {
rules: [
{
test: /\.(jsx|js)$/,
exclude: /node_modules/,
use: ["babel-loader"],
enforce: "pre"
},
{
test: /\.(c|sa|sc)ss$/,
exclude: /node_modules/,
use: [
isDevelopment
? { loader: "style-loader" }
: { loader: MiniCssExtractPlugin.loader },
{ loader: "css-loader", options: { sourceMap: isDevelopment } },
{
loader: "sass-loader",
options: {
implementation: require("sass"),
fiber: Fiber
}
}
]
},
{
test: /\.(eot|svg|ttf|woff|woff2|otf)$/,
use: {
loader: "file-loader",
options: {
name: "[path][name].[ext]"
}
}
}
]
},
optimization: {
splitChunks: {
cacheGroups: {
styles: {
name: "styles",
test: /\.(c|sc|sa)ss$/,
chunks: "all",
enforce: true
}
}
},
minimize: isProduction
},
resolve: {
extensions: [".js", ".jsx", ".json"]
},
plugins: [
new webpack.ProvidePlugin({
RCLOADABLE: [path.resolve(libPath, "reactLazyLoader"), "default"]
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "docs/index.html"),
chunksSortMode: "none"
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
})
]
};