Files
cms_thermo_active/Thermo.Active/wwwroot/webpack.config.js
T
2020-06-12 16:06:05 +02:00

157 lines
3.4 KiB
JavaScript

var path = require('path')
var webpack = require('webpack')
const { VueLoaderPlugin } = require('vue-loader');
const TerserPlugin = require('terser-webpack-plugin');
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
let isProduction = process.argv.some(i => i === 'production');
if (isProduction) console.log("Building for PRODUCTION Environment!");
const optimization = {
splitChunks: {
chunks: 'all',
// maxInitialRequests: Infinity,
// minSize: 0,
// cacheGroups: {
// vendor: {
// test: /[\\/]node_modules[\\/]/,
// name: true,
// chunks: 'all',
// },
// }
},
// runtimeChunk: true,
// removeAvailableModules: true,
// removeEmptyChunks: true,
// flagIncludedChunks: true
};
module.exports = {
mode: "development",
optimization,
devServer: {
contentBase: __dirname,
historyApiFallback: true,
port: 8900
// hot: true,
},
entry: ['./src/main.ts'],
output: {
path: path.resolve(__dirname, './dist'),
publicPath: 'dist/',
filename: 'build.js',
chunkFilename: "[name].js"
},
resolve: {
extensions: ['.ts', '.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'src': path.resolve('src'),
"@": path.resolve("src"),
}
},
module: {
rules: [
{
test: /\.vue$/,
// exclude: /(node_modules|bower_components|libs)/,
use: {
loader: "vue-loader",
options: {
loaders: {},
name: "[name].[ext]"
}
}
},
{
test: /\.tsx?$/,
exclude: /(node_modules|bower_components|libs)/,
use: [
{ loader: "babel-loader" },
{
loader: "ts-loader",
options: {
appendTsSuffixTo: [/\.vue$/]
}
}
]
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components|libs)/,
use: {
loader: "babel-loader",
options: {}
}
},
{
test: /\.(png|jpg|gif|svg)$/,
use: {
loader: "file-loader",
options: {
name: "[name].[ext]"
}
}
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
]
},
performance: {
hints: false
},
devtool: 'cheap-module-eval-source-map',
plugins: [
new VueLoaderPlugin(),
]
}
if (process.env.NODE_ENV === 'production' || isProduction) {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
//new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
},
PRODUCTION: true
}),
// new webpack.optimize.UglifyJsPlugin({
// sourceMap: true,
// compress: {
// warnings: false
// }
// }),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
module.exports.optimization = Object.assign({}, optimization, {
minimize: true,
minimizer: [
new TerserPlugin({
cache: true,
parallel: false,
sourceMap: false,
terserOptions: {
module: true,
// ecma: 6,
output: {
comments: false,
},
}
})
]
});
}