2022-06-21 10:33:35 +00:00
|
|
|
const path = require('path')
|
|
|
|
const GlobImporter = require('node-sass-glob-importer')
|
|
|
|
const TerserPlugin = require("terser-webpack-plugin")
|
|
|
|
|
|
|
|
const isDev = process.env.NODE_ENV === 'development'
|
|
|
|
|
2022-08-02 20:09:45 +00:00
|
|
|
const buildTarget = process.env.BUILD_TARGET ?? 'app'
|
|
|
|
|
2022-06-21 10:33:35 +00:00
|
|
|
module.exports = {
|
|
|
|
mode: isDev ? 'development' : 'production',
|
|
|
|
watch: isDev,
|
|
|
|
|
|
|
|
devtool: isDev ? 'cheap-module-source-map' : 'source-map',
|
|
|
|
|
|
|
|
entry: [
|
|
|
|
'./assets/scripts/main.js',
|
|
|
|
'./assets/styles/main.scss'
|
|
|
|
],
|
|
|
|
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, './public/dist/'),
|
|
|
|
filename: 'app.min.js',
|
|
|
|
},
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [{
|
|
|
|
test: /\.(scss)/,
|
2022-08-02 20:09:45 +00:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
2022-06-21 10:33:35 +00:00
|
|
|
options: {
|
|
|
|
outputPath: './',
|
2022-08-02 20:09:45 +00:00
|
|
|
name: buildTarget + '.min.css'
|
2022-06-21 10:33:35 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
2022-08-02 20:09:45 +00:00
|
|
|
additionalData: "$buildTarget: " + (buildTarget) + ';',
|
2022-06-21 10:33:35 +00:00
|
|
|
sassOptions: {
|
|
|
|
importer: GlobImporter(),
|
|
|
|
outputStyle: "compressed"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
plugins: [],
|
|
|
|
optimization: {
|
|
|
|
minimize: true,
|
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin()
|
|
|
|
]
|
|
|
|
}
|
2022-08-02 20:09:45 +00:00
|
|
|
}
|