forked from liqd/a4-speakup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
107 lines (105 loc) · 2.79 KB
/
webpack.common.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const webpack = require('webpack')
const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = {
entry: {
adhocracy4: [
'./a4-speakup/assets/scss/style.scss',
'./a4-speakup/assets/js/app.js'
],
vendor: [
'classnames',
'@fortawesome/fontawesome-free/scss/fontawesome.scss',
'@fortawesome/fontawesome-free/scss/brands.scss',
'@fortawesome/fontawesome-free/scss/regular.scss',
'@fortawesome/fontawesome-free/scss/solid.scss',
'jquery',
'js-cookie',
'react',
'immutability-helper',
'react-dom',
'react-flip-move'
],
datepicker: [
'./a4-speakup/assets/js/init-picker.js',
'datepicker/css/datepicker.min.css'
]
},
output: {
libraryTarget: 'this',
library: '[name]',
path: path.resolve('./a4-speakup/static/'),
publicPath: '/static/',
filename: '[name].js'
},
externals: {
'django': 'django'
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules\/(?!(adhocracy4|bootstrap)\/).*/, // exclude all dependencies but adhocracy4 and bootstrap
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'].map(require.resolve),
plugins: ['@babel/plugin-transform-runtime', '@babel/plugin-transform-modules-commonjs']
}
},
{
test: /\.s?css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
},
{
test: /(fonts|files)\/.*\.(svg|woff2?|ttf|eot|otf)(\?.*)?$/,
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]'
}
},
{
test: /\.svg$|\.png$/,
loader: 'file-loader',
options: {
name: 'images/[name].[ext]'
}
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx', '.scss', '.css'],
alias: {
'jquery$': 'jquery/dist/jquery.min.js'
},
// when using `npm link`, dependencies are resolved against the linked
// folder by default. This may result in dependencies being included twice.
// Setting `resolve.root` forces webpack to resolve all dependencies
// against the local directory.
modules: [path.resolve('./node_modules')]
},
plugins: [
new webpack.ProvidePlugin({
timeago: 'timeago.js'
}),
new webpack.optimize.SplitChunksPlugin({
name: 'vendor',
filename: 'vendor.js'
}),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css'
}),
new CopyWebpackPlugin([
{
from: './a4-speakup/assets/images/**/*',
to: 'images/',
flatten: true
}
])
]
}