@cocreate/selection 1.6.27 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +21 -0
- package/CoCreate.config.js +2 -2
- package/LICENSE +177 -178
- package/docs/index.html +19 -19
- package/package.json +4 -5
- package/src/index.js +166 -166
- package/webpack.config.js +79 -73
package/webpack.config.js
CHANGED
@@ -1,84 +1,90 @@
|
|
1
1
|
const path = require("path")
|
2
2
|
const TerserPlugin = require("terser-webpack-plugin")
|
3
3
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
4
|
-
let isProduction = process.env.NODE_ENV === "production"
|
5
4
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
|
6
5
|
|
7
|
-
module.exports = {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
output: {
|
12
|
-
path: path.resolve(__dirname, "dist"),
|
13
|
-
filename: isProduction ? "[name].min.js" : "[name].js",
|
14
|
-
libraryTarget: "umd",
|
15
|
-
libraryExport: "default",
|
16
|
-
library: ["CoCreate", "selection"],
|
17
|
-
globalObject: "this",
|
18
|
-
},
|
6
|
+
module.exports = (env, argv) => {
|
7
|
+
let isProduction = false
|
8
|
+
if (argv.mode === 'production')
|
9
|
+
isProduction = true
|
19
10
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
filename: "[name].css",
|
24
|
-
}),
|
25
|
-
],
|
26
|
-
// Default mode for Webpack is production.
|
27
|
-
// Depending on mode Webpack will apply different things
|
28
|
-
// on final bundle. For now we don't need production's JavaScript
|
29
|
-
// minifying and other thing so let's set mode to development
|
30
|
-
mode: isProduction ? "production" : "development",
|
31
|
-
module: {
|
32
|
-
rules: [
|
33
|
-
{
|
34
|
-
test: /.js$/,
|
35
|
-
exclude: /(node_modules)/,
|
36
|
-
use: {
|
37
|
-
loader: "babel-loader",
|
38
|
-
options: {
|
39
|
-
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
40
|
-
},
|
11
|
+
const config = {
|
12
|
+
entry: {
|
13
|
+
"CoCreate-selection": "./src/index.js",
|
41
14
|
},
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
15
|
+
output: {
|
16
|
+
path: path.resolve(__dirname, "dist"),
|
17
|
+
filename: isProduction ? "[name].min.js" : "[name].js",
|
18
|
+
libraryTarget: "umd",
|
19
|
+
libraryExport: "default",
|
20
|
+
library: ["CoCreate", "selection"],
|
21
|
+
globalObject: "this",
|
22
|
+
},
|
23
|
+
|
24
|
+
plugins: [
|
25
|
+
new CleanWebpackPlugin(),
|
26
|
+
new MiniCssExtractPlugin({
|
27
|
+
filename: "[name].css",
|
28
|
+
}),
|
48
29
|
],
|
49
|
-
|
50
|
-
|
51
|
-
|
30
|
+
// Default mode for Webpack is production.
|
31
|
+
// Depending on mode Webpack will apply different things
|
32
|
+
// on final bundle. For now we don't need production's JavaScript
|
33
|
+
// minifying and other thing so let's set mode to development
|
34
|
+
mode: isProduction ? "production" : "development",
|
35
|
+
module: {
|
36
|
+
rules: [
|
37
|
+
{
|
38
|
+
test: /.js$/,
|
39
|
+
exclude: /(node_modules)/,
|
40
|
+
use: {
|
41
|
+
loader: "babel-loader",
|
42
|
+
options: {
|
43
|
+
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
44
|
+
},
|
45
|
+
},
|
46
|
+
},
|
47
|
+
{
|
48
|
+
test: /.css$/i,
|
49
|
+
use: [
|
50
|
+
{ loader: "style-loader", options: { injectType: "linkTag" } },
|
51
|
+
"file-loader",
|
52
|
+
],
|
53
|
+
},
|
54
|
+
],
|
55
|
+
},
|
52
56
|
|
53
|
-
|
54
|
-
|
57
|
+
// add source map
|
58
|
+
...(isProduction ? {} : { devtool: "eval-source-map" }),
|
55
59
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
60
|
+
optimization: {
|
61
|
+
minimize: true,
|
62
|
+
minimizer: [
|
63
|
+
new TerserPlugin({
|
64
|
+
extractComments: true,
|
65
|
+
// cache: true,
|
66
|
+
parallel: true,
|
67
|
+
// sourceMap: true, // Must be set to true if using source-maps in production
|
68
|
+
terserOptions: {
|
69
|
+
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
|
70
|
+
// extractComments: 'all',
|
71
|
+
compress: {
|
72
|
+
drop_console: true,
|
73
|
+
},
|
74
|
+
},
|
75
|
+
}),
|
76
|
+
],
|
77
|
+
splitChunks: {
|
78
|
+
chunks: "all",
|
79
|
+
minSize: 200,
|
80
|
+
// maxSize: 99999,
|
81
|
+
//minChunks: 1,
|
78
82
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
}
|
83
|
+
cacheGroups: {
|
84
|
+
defaultVendors: false,
|
85
|
+
},
|
86
|
+
},
|
87
|
+
},
|
88
|
+
}
|
89
|
+
return config
|
90
|
+
}
|