|
@ -5,14 +5,10 @@ const path = require('path'); |
|
|
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin'); |
|
|
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin'); |
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin'); |
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin'); |
|
|
const ImageminPlugin = require('imagemin-webpack-plugin').default; |
|
|
const ImageminPlugin = require('imagemin-webpack-plugin').default; |
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
|
|
|
|
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); |
|
|
|
|
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); |
|
|
|
|
|
|
|
|
module.exports = function(env, argv) { |
|
|
module.exports = function(env, argv) { |
|
|
if (env === undefined) { |
|
|
|
|
|
env = {}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
env = env || {}; |
|
|
const production = !!env.production; |
|
|
const production = !!env.production; |
|
|
|
|
|
|
|
|
const quick = !production && !!env.quick; |
|
|
const quick = !production && !!env.quick; |
|
@ -34,14 +30,14 @@ module.exports = function(env, argv) { |
|
|
// inlineSource: '.(js|css)$',
|
|
|
// inlineSource: '.(js|css)$',
|
|
|
minify: minify |
|
|
minify: minify |
|
|
? { |
|
|
? { |
|
|
removeComments: true, |
|
|
|
|
|
collapseWhitespace: true, |
|
|
|
|
|
removeRedundantAttributes: true, |
|
|
|
|
|
useShortDoctype: true, |
|
|
|
|
|
removeEmptyAttributes: true, |
|
|
|
|
|
removeStyleLinkTypeAttributes: true, |
|
|
|
|
|
keepClosingSlash: true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
removeComments: true, |
|
|
|
|
|
collapseWhitespace: true, |
|
|
|
|
|
removeRedundantAttributes: true, |
|
|
|
|
|
useShortDoctype: true, |
|
|
|
|
|
removeEmptyAttributes: true, |
|
|
|
|
|
removeStyleLinkTypeAttributes: true, |
|
|
|
|
|
keepClosingSlash: true |
|
|
|
|
|
} |
|
|
: false |
|
|
: false |
|
|
}), |
|
|
}), |
|
|
new HtmlWebpackPlugin({ |
|
|
new HtmlWebpackPlugin({ |
|
@ -54,31 +50,17 @@ module.exports = function(env, argv) { |
|
|
// inlineSource: '.(js|css)$',
|
|
|
// inlineSource: '.(js|css)$',
|
|
|
minify: minify |
|
|
minify: minify |
|
|
? { |
|
|
? { |
|
|
removeComments: true, |
|
|
|
|
|
collapseWhitespace: true, |
|
|
|
|
|
removeRedundantAttributes: true, |
|
|
|
|
|
useShortDoctype: true, |
|
|
|
|
|
removeEmptyAttributes: true, |
|
|
|
|
|
removeStyleLinkTypeAttributes: true, |
|
|
|
|
|
keepClosingSlash: true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
removeComments: true, |
|
|
|
|
|
collapseWhitespace: true, |
|
|
|
|
|
removeRedundantAttributes: true, |
|
|
|
|
|
useShortDoctype: true, |
|
|
|
|
|
removeEmptyAttributes: true, |
|
|
|
|
|
removeStyleLinkTypeAttributes: true, |
|
|
|
|
|
keepClosingSlash: true |
|
|
|
|
|
} |
|
|
: false |
|
|
: false |
|
|
}), |
|
|
}), |
|
|
new HtmlWebpackInlineSourcePlugin(), |
|
|
|
|
|
new UglifyJsPlugin({ |
|
|
|
|
|
parallel: true, |
|
|
|
|
|
sourceMap: sourceMaps, |
|
|
|
|
|
uglifyOptions: { |
|
|
|
|
|
ecma: 5, |
|
|
|
|
|
compress: minify, |
|
|
|
|
|
mangle: minify, |
|
|
|
|
|
output: { |
|
|
|
|
|
beautify: !minify, |
|
|
|
|
|
comments: false, |
|
|
|
|
|
ecma: 5 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
new HtmlWebpackInlineSourcePlugin() |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
if (!quick) { |
|
|
if (!quick) { |
|
@ -109,6 +91,7 @@ module.exports = function(env, argv) { |
|
|
// main: ['./scss/main.scss']
|
|
|
// main: ['./scss/main.scss']
|
|
|
}, |
|
|
}, |
|
|
mode: production ? 'production' : 'development', |
|
|
mode: production ? 'production' : 'development', |
|
|
|
|
|
devtool: sourceMaps ? 'eval-source-map' : undefined, |
|
|
output: { |
|
|
output: { |
|
|
filename: '[name].js', |
|
|
filename: '[name].js', |
|
|
path: path.resolve(__dirname, '../../', 'out/ui'), |
|
|
path: path.resolve(__dirname, '../../', 'out/ui'), |
|
@ -116,26 +99,25 @@ module.exports = function(env, argv) { |
|
|
}, |
|
|
}, |
|
|
optimization: { |
|
|
optimization: { |
|
|
splitChunks: { |
|
|
splitChunks: { |
|
|
cacheGroups: { |
|
|
|
|
|
styles: { |
|
|
|
|
|
name: 'styles', |
|
|
|
|
|
test: /\.css$/, |
|
|
|
|
|
chunks: 'all', |
|
|
|
|
|
enforce: true |
|
|
|
|
|
|
|
|
cacheGroups: { |
|
|
|
|
|
styles: { |
|
|
|
|
|
name: 'styles', |
|
|
|
|
|
test: /\.css$/, |
|
|
|
|
|
chunks: 'all', |
|
|
|
|
|
enforce: true |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
resolve: { |
|
|
resolve: { |
|
|
extensions: ['.ts', '.js'], |
|
|
|
|
|
|
|
|
extensions: ['.tsx', '.ts', '.js'], |
|
|
modules: [path.resolve(__dirname), 'node_modules'] |
|
|
modules: [path.resolve(__dirname), 'node_modules'] |
|
|
}, |
|
|
}, |
|
|
devtool: sourceMaps ? 'eval-source-map' : undefined, |
|
|
|
|
|
module: { |
|
|
module: { |
|
|
rules: [ |
|
|
rules: [ |
|
|
{ |
|
|
{ |
|
|
test: /\.ts$/, |
|
|
|
|
|
use: [{ loader: 'ts-loader' }], |
|
|
|
|
|
|
|
|
test: /\.tsx?$/, |
|
|
|
|
|
use: 'ts-loader', |
|
|
exclude: /node_modules/ |
|
|
exclude: /node_modules/ |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|