-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
599da59
commit 61524cb
Showing
4 changed files
with
111 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,85 @@ | ||
// Webpack uses this to work with directories | ||
const path = require('path'); | ||
const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); | ||
// const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
// const { CleanWebpackPlugin } = require('clean-webpack-plugin'); | ||
const path = require("path") | ||
const TerserPlugin = require("terser-webpack-plugin") | ||
const MiniCssExtractPlugin = require("mini-css-extract-plugin") | ||
let isProduction = process.env.NODE_ENV === "production" | ||
const { CleanWebpackPlugin } = require("clean-webpack-plugin") | ||
|
||
let isProduction = process.env.NODE_ENV === 'production'; | ||
|
||
// This is main configuration object. | ||
// Here you write different options and tell Webpack what to do | ||
module.exports = { | ||
|
||
// Path to your entry point. From this file Webpack will begin his work | ||
entry: { | ||
'CoCreate-croppie': './src/CoCreate-croppie.js', | ||
"CoCreate-croppie": "./src/index.js", | ||
}, | ||
|
||
// Path and filename of your result bundle. | ||
// Webpack will bundle all JavaScript into this file | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: isProduction ? '[name].min.js' : '[name].js', | ||
libraryTarget: 'umd', | ||
libraryExport: 'default', | ||
library: ['CoCreate', 'croppie'], | ||
path: path.resolve(__dirname, "dist"), | ||
filename: isProduction ? "[name].min.js" : "[name].js", | ||
libraryTarget: "umd", | ||
libraryExport: "default", | ||
library: ["CoCreate", "croppie"], | ||
globalObject: "this", | ||
// publicPath: 'https://server.cocreate.app/CoCreateJS/dist/' | ||
}, | ||
|
||
plugins: [ | ||
new CleanWebpackPlugin(), | ||
new MiniCssExtractPlugin({ | ||
filename: "[name].css", | ||
}), | ||
], | ||
// Default mode for Webpack is production. | ||
// Depending on mode Webpack will apply different things | ||
// on final bundle. For now we don't need production's JavaScript | ||
// minifying and other thing so let's set mode to development | ||
mode: isProduction ? 'production' : 'development', | ||
mode: isProduction ? "production" : "development", | ||
module: { | ||
rules: [{ | ||
test: /\.js$/, | ||
rules: [ | ||
{ | ||
test: /.js$/, | ||
exclude: /(node_modules)/, | ||
use: { | ||
loader: 'babel-loader', | ||
loader: "babel-loader", | ||
options: { | ||
presets: ['@babel/preset-env'] | ||
} | ||
} | ||
plugins: ["@babel/plugin-transform-modules-commonjs"], | ||
}, | ||
}, | ||
}, | ||
] | ||
{ | ||
test: /.css$/i, | ||
use: [ | ||
{ loader: "style-loader", options: { injectType: "linkTag" } }, | ||
"file-loader", | ||
], | ||
}, | ||
], | ||
}, | ||
|
||
// add source map | ||
...(isProduction ? {} : { devtool: 'eval-source-map' }), | ||
...(isProduction ? {} : { devtool: "eval-source-map" }), | ||
|
||
// add uglifyJs | ||
optimization: { | ||
minimizer: [new UglifyJsPlugin({ | ||
uglifyOptions: { | ||
// get options: https://github.com/mishoo/UglifyJS | ||
drop_console: isProduction | ||
minimize: true, | ||
minimizer: [ | ||
new TerserPlugin({ | ||
extractComments: true, | ||
// cache: true, | ||
parallel: true, | ||
// sourceMap: true, // Must be set to true if using source-maps in production | ||
terserOptions: { | ||
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions | ||
// extractComments: 'all', | ||
compress: { | ||
drop_console: true, | ||
}, | ||
}, | ||
}), | ||
], | ||
splitChunks: { | ||
chunks: "all", | ||
minSize: 200, | ||
// maxSize: 99999, | ||
//minChunks: 1, | ||
|
||
cacheGroups: { | ||
defaultVendors: false, | ||
}, | ||
})], | ||
}, | ||
}, | ||
|
||
}; | ||
} |