2019-11-29 16:53:50 +01:00
|
|
|
const path = require('path');
|
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
2020-04-23 12:06:50 +02:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
const csso = require('csso');
|
|
|
|
const fs = require('fs');
|
2019-11-29 16:53:50 +01:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: './js/src/ulogger.js',
|
|
|
|
output: {
|
|
|
|
filename: 'bundle.js',
|
|
|
|
path: path.resolve(__dirname, 'js/dist'),
|
|
|
|
publicPath: 'js/dist/'
|
|
|
|
},
|
2019-12-30 14:01:27 +01:00
|
|
|
plugins: [
|
|
|
|
new CleanWebpackPlugin({
|
|
|
|
cleanOnceBeforeBuildPatterns: [ '**/*', '!.*' ]
|
2020-04-23 12:06:50 +02:00
|
|
|
}),
|
|
|
|
new CopyWebpackPlugin([
|
|
|
|
{
|
|
|
|
from: '{css/src/*.css,node_modules/ol/ol.css,node_modules/chartist/dist/chartist.css}',
|
|
|
|
to: path.resolve(__dirname, 'css/dist'),
|
|
|
|
flatten: true,
|
|
|
|
transform: (content, filename) => {
|
|
|
|
const basename = path.basename(filename);
|
|
|
|
const result = csso.minify(content.toString(), {
|
|
|
|
filename: basename,
|
|
|
|
sourceMap: true
|
|
|
|
});
|
|
|
|
fs.writeFile(`css/dist/${basename}.map`, result.map.toString(), (err) => { if (err) { throw err; }});
|
|
|
|
return `${result.css}\n/*# sourceMappingURL=${basename}.map */`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])
|
2019-12-30 14:01:27 +01:00
|
|
|
],
|
2019-11-29 16:53:50 +01:00
|
|
|
optimization: {
|
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
vendors: {
|
|
|
|
test: /[\\/]node_modules[\\/]|[\\/]ol.js/,
|
|
|
|
name: 'ol'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|