-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.base.js
65 lines (64 loc) · 2.1 KB
/
webpack.config.base.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const FixStyleOnlyEntriesPlugin = require('webpack-remove-empty-scripts');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin')
const config = require('./config.json')
module.exports = {
entry: {
map: './js/map.js',
intro: './js/intro.js',
mapStyle: './style/map.scss',
introStyle: './style/intro.scss',
},
module: {
rules: [{
test: /\.html$/i,
loader: 'html-loader',
}, {
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
}, {
test: /\.(png|jpe?g|gif|ttf|woff|woff2|eot|svg)$/i,
use: ['file-loader']
}, {
test: /\.scss$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', "sass-loader"],
}],
},
plugins: [
new FaviconsWebpackPlugin(),
new CleanWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [
{ from: 'static', to: 'static' }
],
}),
new FixStyleOnlyEntriesPlugin({ ignore: 'webpack-dev-server' }),
new MiniCssExtractPlugin({
filename: '[name].[chunkhash].css'
}),
new HtmlWebpackPlugin({
filename: 'map.html',
chunks: ['map', 'mapStyle'],
template: 'map.ejs',
environment: config
}),
new HtmlWebpackPlugin({
filename: 'intro.html',
chunks: ['intro', 'introStyle'],
template: 'intro.ejs'
}),
new webpack.DefinePlugin({
__BACKEND__: JSON.stringify(config.backend),
__DATA__: JSON.stringify(config.data.list[config.data.default]),
__URL__: JSON.stringify(config.url),
__KEYS__: JSON.stringify(config.keys)
})
],
output: {
publicPath: '/'
}
};