This repository has been archived by the owner on Aug 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
executable file
·101 lines (97 loc) · 2.81 KB
/
webpack.config.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
'use strict';
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const extractSass = new ExtractTextPlugin({
filename: 'stylesheets/application.css',
allChunks: true
});
module.exports = {
target: 'node',
entry: {
common: [
'jquery',
'./node_modules/jquery-migrate/dist/jquery-migrate.js',
'./app/assets/javascripts/details.polyfill.js',
'./app/assets/javascripts/application.js',
'./node_modules/dropzone/dist/dropzone.js',
'./app/assets/javascripts/documentUpload.js',
'./app/assets/javascripts/validation.js',
'./app/assets/javascripts/dynamicFields.js',
'./node_modules/govuk_frontend_toolkit/javascripts/govuk/show-hide-content.js',
'./app/assets/javascripts/disable-enable-button.js'
],
sitemap: './app/steps/sitemap/client.js',
css: './tmp/sass/application.scss'
},
output: {
path: './public/[hash]',
filename: 'javascripts/bundle--[name].js'
},
plugins: [
new webpack.ProvidePlugin({
'window.$': 'jquery',
'window.jQuery': 'jquery',
$: 'jquery',
jQuery: 'jquery'
}),
new CopyWebpackPlugin([
{ from: './tmp/images', to: 'images' },
{ from: './node_modules/govuk_template_mustache/assets/stylesheets', to: 'stylesheets' },
{ from: './node_modules/govuk_template_mustache/assets/javascripts', to: 'javascripts' },
{ from: './node_modules/govuk_template_mustache/assets/images/favicon.ico', to: 'images' }
]),
extractSass,
function() {
this.plugin('done', stats => {
fs.writeFileSync(
path.join(__dirname, 'manifest.json'),
JSON.stringify({ STATIC_ASSET_PATH: stats.hash })
);
});
}
],
module: {
rules: [
{
test: /\.scss$/,
use: extractSass.extract({
use: [
{ loader: 'css-loader' },
{
loader: 'sass-loader',
options: {
includePaths: [
'node_modules/govuk_frontend_toolkit/stylesheets',
'node_modules/govuk_template_mustache/assets/stylesheets',
'node_modules/govuk-elements-sass/public/sass'
]
}
}
]
})
},
{
test: /\.(jpg|png|svg)$/,
use: [
{
loader: 'file-loader',
options: { name: '../images/[name].[ext]' }
}
]
},
{
test: /\.js$/,
use: {
loader: 'babel-loader'
}
}
],
loaders: [
{ test: /public/, loader: 'imports-loader?this=>window' },
{ test: /public/, loader: 'imports-loader?$=jquery' }
]
}
};