-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.common.js
More file actions
52 lines (50 loc) · 1.59 KB
/
webpack.common.js
File metadata and controls
52 lines (50 loc) · 1.59 KB
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
const path = require("path")
const fs = require("fs")
const HtmlWebpackPlugin = require("html-webpack-plugin")
const webpack = require("webpack");
const SVGSpritemapPlugin = require("svg-spritemap-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const pages = fs.readdirSync(path.resolve(__dirname, "src"))
.filter(fileName => fileName.endsWith(".twig"))
/** @type {webpack.Configuration} */
module.exports = {
entry: "./src/js/index.js",
resolve: {
extensions: [".js", ".scss", ".css"],
alias: {
'@': path.resolve(__dirname, 'src'),
assets: path.resolve(__dirname, 'src/assets'),
'vue$': 'vue/dist/vue.esm.js'
}
},
plugins: [
...pages.map(page => new HtmlWebpackPlugin({
template: "src/" + page,
filename: page.replace(".twig", ".html"),
inject: true,
minify: false
})),
new SVGSpritemapPlugin("src/assets/icons/**/*.svg", {
output: {
filename: "assets/icons/icons.svg",
}
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: 'jquery',
"window.jQuery": "jquery",
}),
new CopyPlugin([
{ from: 'src/mocks', to: 'mocks' },
{ from: 'src/assets/favicon', to: 'assets/favicon' },
])
],
optimization: {
splitChunks: {
chunks: 'async'
}
},
externals: {
jquery: 'jQuery'
}
}