101 lines
3.0 KiB
JavaScript
101 lines
3.0 KiB
JavaScript
const path = require( 'path' );
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const TerserPlugin = require( 'terser-webpack-plugin' );
|
|
|
|
module.exports = ( env, argv ) => {
|
|
let devMode = argv.mode !== 'production';
|
|
|
|
let config = {
|
|
entry: {
|
|
default: './TypeScript/app.ts',
|
|
styles: './StyleSheets/styles.scss'
|
|
},
|
|
resolve: {
|
|
extensions: [ '.ts', '.js' ]
|
|
},
|
|
output: {
|
|
filename: '[name].js',
|
|
path: path.resolve( __dirname, '../Resources/Public/JavaScript' )
|
|
},
|
|
plugins: [
|
|
new MiniCssExtractPlugin({
|
|
filename: '../StyleSheets/[name].css'
|
|
})
|
|
],
|
|
cache: {
|
|
type: 'filesystem',
|
|
cacheDirectory: path.resolve( __dirname, '.temp_cache' )
|
|
},
|
|
devtool: devMode ? 'source-map' : false,
|
|
module: {
|
|
rules: [ {
|
|
test: /\.tsx?$/,
|
|
loader: "awesome-typescript-loader",
|
|
options: {
|
|
configFileName: 'tsconfig.json'
|
|
}
|
|
}, {
|
|
test: /\.(woff2?|ttf|otf|eot|svg)$/,
|
|
loader: "file-loader",
|
|
options: {
|
|
name: "../StyleSheets/Fonts/[name].[ext]"
|
|
}
|
|
}, {
|
|
test: /.*Images\/Frontend(?!\/leaflet).*\.(png|svg)$/,
|
|
loader: "file-loader",
|
|
options: {
|
|
outputPath: '../Images/Frontend/',
|
|
name: '[name].[ext]'
|
|
}
|
|
}, {
|
|
test: /\.s?[ac]ss$/,
|
|
use: [{
|
|
loader: MiniCssExtractPlugin.loader,
|
|
options: {
|
|
}
|
|
}, {
|
|
loader: 'css-loader'
|
|
}, {
|
|
loader: 'postcss-loader',
|
|
options: {
|
|
sourceMap: devMode,
|
|
postcssOptions: {
|
|
plugins: () => [ require( 'autoprefixer' ) ]
|
|
}
|
|
}
|
|
}, {
|
|
loader: 'sass-loader',
|
|
options: {
|
|
sourceMap: devMode,
|
|
sassOptions: {
|
|
outputStyle: devMode ? 'expanded' : 'compressed'
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
watchOptions: {
|
|
poll: true,
|
|
ignored: ['node_modules/**','public/**','var/**','vendor/**'],
|
|
aggregateTimeout: 300
|
|
},
|
|
optimization: {
|
|
minimize: !devMode,
|
|
minimizer: [ new TerserPlugin({
|
|
test: /\.js(\?.*)?$/i,
|
|
parallel: true,
|
|
terserOptions: {
|
|
sourceMap: true
|
|
}
|
|
}) ],
|
|
},
|
|
performance: {
|
|
hints: devMode ? "error" : false
|
|
}
|
|
}
|
|
return config;
|
|
};
|
|
|