merge with old webpack.conf from admin

This commit is contained in:
Daniel Hübleitner
2019-07-28 12:51:35 +02:00
parent 1926e255c3
commit f91ad84664
+158 -114
View File
@@ -13,127 +13,171 @@ const TEMPLATE_FILE = path.resolve(APP_PATH, 'index.html');
const BUILD_PATH = path.resolve(ROOT_PATH, './static'); const BUILD_PATH = path.resolve(ROOT_PATH, './static');
const staticFiles = { const staticFiles = [
mode: 'production', {
entry: { mode: 'production',
app: ENTRY_FILE, entry: {
vendor: [ app: ENTRY_FILE,
"angular", vendor: [
'@uirouter/angularjs' "angular",
] '@uirouter/angularjs'
}, ]
output: { },
path: BUILD_PATH, output: {
filename: 'js/[name].[hash:8].js', path: BUILD_PATH,
chunkFilename: 'js/[name].[chunkhash:8].js' filename: 'js/[name].[hash:8].js',
}, chunkFilename: 'js/[name].[chunkhash:8].js'
module: { },
rules: [ module: {
{ rules: [
test: /\.html$/, {
use: { test: /\.html$/,
loader: 'html-loader', use: {
options: { loader: 'html-loader',
exportAsEs6Default: true, options: {
minimize: true, exportAsEs6Default: true,
removeComments: true minimize: true,
removeComments: true
}
}
},
{
test: /\.css$/,
exclude: NODE_MODULES_PATH,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'],
include: APP_PATH
},
{
test: /\.less$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'less-loader'],
},
{
test: /\.scss$/,
exclude: NODE_MODULES_PATH,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader'],
include: APP_PATH
},
{
test: /\.(eot|woff|ttf|woff2)(\?|$)/,
exclude: NODE_MODULES_PATH,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
},
include: APP_PATH
},
{
test: /\.(png|jpg|gif|svg)$/,
exclude: NODE_MODULES_PATH,
use: {
loader: 'url-loader',
options: {
limit: 8192,
name: 'images/[name].[hash:8].[ext]'
}
},
include: APP_PATH
},
{
test: /\.ts$/,
exclude: NODE_MODULES_PATH,
use: 'ts-loader',
include: APP_PATH
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new HtmlWebpackPlugin({
filename: path.resolve(BUILD_PATH, 'index.html'),
template: TEMPLATE_FILE,
hash: false,
}),
new CleanWebpackPlugin(['./static'], {
root: path.resolve(__dirname, './'),
verbose: true
}),
new MiniCssExtractPlugin({
filename: 'css/[name].css?v=[contenthash:8]'
})
],
optimization: {
splitChunks: {
cacheGroups: {
common: {
chunks: 'all',
minChunks: 2,
maxInitialRequests: 5,
minSize: 0,
name: 'common'
},
vendor: {
test: /node_modules/,
chunks: 'all',
name: 'vendor',
priority: 10,
enforce: true,
minChunks: 2
} }
} }
},
{
test: /\.css$/,
exclude: NODE_MODULES_PATH,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'],
include: APP_PATH
},
{
test: /\.less$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'less-loader'],
},
{
test: /\.scss$/,
exclude: NODE_MODULES_PATH,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader'],
include: APP_PATH
},
{
test: /\.(eot|woff|ttf|woff2)(\?|$)/,
exclude: NODE_MODULES_PATH,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
},
include: APP_PATH
},
{
test: /\.(png|jpg|gif|svg)$/,
exclude: NODE_MODULES_PATH,
use: {
loader: 'url-loader',
options: {
limit: 8192,
name: 'images/[name].[hash:8].[ext]'
}
},
include: APP_PATH
},
{
test: /\.ts$/,
exclude: NODE_MODULES_PATH,
use: 'ts-loader',
include: APP_PATH
} }
] },
}, resolve: {
plugins: [ extensions: ['.js', '.ts', '.less', '.scss', '.css'],
new webpack.DefinePlugin({ alias: {
'process.env': { '@': APP_PATH,
NODE_ENV: JSON.stringify('production')
}
}),
new HtmlWebpackPlugin({
filename: path.resolve(BUILD_PATH, 'index.html'),
template: TEMPLATE_FILE,
hash: false,
}),
new CleanWebpackPlugin(['./static'], {
root: path.resolve(__dirname, './'),
verbose: true
}),
new MiniCssExtractPlugin({
filename: 'css/[name].css?v=[contenthash:8]'
})
],
optimization: {
splitChunks: {
cacheGroups: {
common: {
chunks: 'all',
minChunks: 2,
maxInitialRequests: 5,
minSize: 0,
name: 'common'
},
vendor: {
test: /node_modules/,
chunks: 'all',
name: 'vendor',
priority: 10,
enforce: true,
minChunks: 2
}
} }
} }
}, },
resolve: { {
extensions: ['.js', '.ts', '.less', '.scss', '.css'], mode: 'production',
alias: { entry: path.resolve(__dirname, 'lib/FrontblockLib.js'),
'@': APP_PATH, output: {
path: path.resolve(__dirname, 'static'),
filename: 'FrontblockLib.js',
},
module: {
rules: [
{ test: /\FrontblockLib.ts/, use: 'ts-loader' }
]
},
optimization: {
minimizer: [new TerserPlugin({
cache: true,
parallel: true,
terserOptions:{
mangle: false,
keep_classnames: true
}
})],
splitChunks: {
cacheGroups: {
common: {
chunks: 'all',
minChunks: 2,
maxInitialRequests: 5,
minSize: 0,
name: 'common'
},
vendor: {
test: /node_modules/,
chunks: 'all',
name: 'vendor',
priority: 10,
enforce: true,
minChunks: 2
}
}
}
} }
} }
}; ]
const plugin = { const plugin = {
target: "node", target: "node",
@@ -190,4 +234,4 @@ const plugin = {
module.exports = [ module.exports = [
Object.assign({}, staticFiles), Object.assign({}, staticFiles),
Object.assign({}, plugin), Object.assign({}, plugin),
]; ];