-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4061af
commit ab0d575
Showing
10 changed files
with
4,869 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
public/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Button } from 'govuk-frontend' | ||
|
||
const $buttons = document.querySelectorAll('[data-module="govuk-button"]') | ||
|
||
$buttons.forEach(($button) => { | ||
new Button($button).init() | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$govuk-is-ie8: true; | ||
|
||
@import "app"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import "govuk-frontend/govuk/all"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title>GOV.UK Frontend</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> | ||
<!--[if !IE 8]><!--> | ||
<link rel="stylesheet" href="../../public/css/app.css"> | ||
<!--<![endif]--> | ||
<!--[if lt IE 9]> | ||
<script src="/vendor/html5-shiv/html5shiv.js"></script> | ||
<![endif]--> | ||
<!--[if IE 8]> | ||
<link rel="stylesheet" href="/public/css/app-old-ie.css"> | ||
<![endif]--> | ||
</head> | ||
<body> | ||
<div class="govuk-width-container"> | ||
<div class="app-whitespace-highlight"> | ||
<a href="/" role="button" class="govuk-button">Link button</a> | ||
<html lang="en" class="govuk-template"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>GOV.UK Frontend</title> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> | ||
<meta name="theme-color" content="#0b0c0c"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
|
||
<!--[if !IE 8]><!--> | ||
<link rel="stylesheet" href="/assets/stylesheets/app.css"> | ||
<!--<![endif]--> | ||
<!--[if IE 8]> | ||
<link rel="stylesheet" href="/assets/stylesheets/app-ie8.css"> | ||
<![endif]--> | ||
<!--[if lt IE 9]> | ||
<script src="/assets/javascripts/html5shiv.min.js"></script> | ||
<![endif]--> | ||
</head> | ||
<body class="govuk-template__body"> | ||
<script>document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');</script> | ||
|
||
<div class="govuk-width-container"> | ||
<main class="govuk-main-wrapper" id="main-content" role="main"> | ||
<a href="/" role="button" draggable="false" class="govuk-button" data-module="govuk-button"> | ||
Link button | ||
</a> | ||
</main> | ||
</div> | ||
</div> | ||
<!--script src="../../../public/all/all.js"></script--> | ||
<script src="public/main.js"></script> | ||
</body> | ||
|
||
<script src="/assets/javascripts/main.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
{ | ||
"name": "webpack-boilerplate", | ||
"description": "Webpack4 boilerplate consuming govuk-frontend", | ||
"private": true, | ||
"name": "govuk-frontend-webpack-boilerplate", | ||
"description": "Boilerplate example for govuk-frontend using webpack", | ||
"scripts": { | ||
"dev": "cross-env NODE_ENV=dev webpack-dev-server --progress --mode development --config webpack.config.js", | ||
"build": "webpack -p --progress --mode production --config webpack.config.js" | ||
"dev": "webpack serve --progress --mode development", | ||
"build": "webpack --progress --mode production" | ||
}, | ||
"dependencies": { | ||
"govuk-frontend": "*" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "^6.26.0", | ||
"babel-loader": "^7.1.4", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-es3": "^1.0.1", | ||
"clean-webpack-plugin": "0.1.19", | ||
"cross-env": "5.1.4", | ||
"css-loader": "0.28.11", | ||
"file-loader": "1.1.11", | ||
"html-webpack-plugin": "3.2.0", | ||
"node-sass": "^4.7.2", | ||
"sass-loader": "7.0.1", | ||
"style-loader": "0.20.3", | ||
"uglifyjs-webpack-plugin": "^1.2.4", | ||
"url-loader": "1.0.1", | ||
"webpack": "4.6.0", | ||
"webpack-cli": "2.0.14", | ||
"webpack-dev-server": ">=3.1.11", | ||
"webpack-merge": "4.1.2" | ||
"babel-loader": "^8.2.5", | ||
"clean-webpack-plugin": "^4.0.0", | ||
"copy-webpack-plugin": "^11.0.0", | ||
"html5shiv": "^3.7.3", | ||
"postcss-loader": "^7.0.1", | ||
"sass": "^1.55.0", | ||
"sass-loader": "^13.0.2", | ||
"terser-webpack-plugin": "^5.3.6", | ||
"webpack": "^5.74.0", | ||
"webpack-cli": "^4.10.0", | ||
"webpack-dev-server": "^4.11.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,114 @@ | ||
const path = require('path') | ||
const UglifyJsPlugin = require('uglifyjs-webpack-plugin') | ||
const { dirname, resolve } = require('path') | ||
|
||
const config = { | ||
mode: 'production', | ||
devtool: 'source-map', | ||
optimization: { | ||
minimizer: [ | ||
new UglifyJsPlugin({ | ||
cache: true, | ||
parallel: true, | ||
sourceMap: true, | ||
uglifyOptions: { | ||
compress: { | ||
ie8: true, | ||
warnings: false | ||
}, | ||
mangle: { | ||
ie8: true | ||
}, | ||
output: { | ||
comments: false, | ||
ie8: true | ||
} | ||
} | ||
}) | ||
] | ||
const { CleanWebpackPlugin } = require('clean-webpack-plugin') | ||
const CopyPlugin = require('copy-webpack-plugin') | ||
const TerserPlugin = require('terser-webpack-plugin') | ||
|
||
// Module resolution | ||
const frontendPath = dirname(require.resolve('govuk-frontend')) | ||
const html5shivPath = dirname(require.resolve('html5shiv')) | ||
const webpackPath = dirname(require.resolve('webpack/package.json')) | ||
const modulesPath = resolve(webpackPath, '../') | ||
|
||
module.exports = ({ WEBPACK_SERVE }, { mode }) => ({ | ||
devServer: { | ||
watchFiles: { | ||
paths: ['**/*.html'] | ||
} | ||
}, | ||
entry: './assets/main.js', | ||
|
||
devtool: WEBPACK_SERVE | ||
? 'inline-source-map' | ||
: 'source-map', | ||
|
||
entry: [ | ||
'./assets/javascripts/main.mjs', | ||
'./assets/stylesheets/app.scss', | ||
'./assets/stylesheets/app-ie8.scss' | ||
], | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
test: /\.(cjs|js|mjs)$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
presets: ['env', 'es3'] | ||
rootMode: 'upward' | ||
} | ||
} | ||
}, | ||
{ | ||
generator: { | ||
outputPath: 'assets/stylesheets', | ||
publicPath: '/assets/stylesheets', | ||
filename: '[name].css' | ||
}, | ||
test: /\.scss$/, | ||
type: 'asset', | ||
use: [ | ||
'postcss-loader', | ||
{ | ||
loader: 'sass-loader', | ||
options: { | ||
sassOptions: { | ||
quietDeps: true | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
|
||
optimization: { | ||
minimize: mode === 'production', | ||
minimizer: [new TerserPlugin({ | ||
extractComments: true, | ||
terserOptions: { | ||
ecma: 5, | ||
format: { comments: false }, | ||
ie8: true, | ||
safari10: true | ||
} | ||
})] | ||
}, | ||
|
||
output: { | ||
path: path.resolve(__dirname, 'public'), | ||
filename: '[name].js', | ||
sourceMapFilename: '[name].js.map' | ||
} | ||
} | ||
clean: true, | ||
filename: 'assets/javascripts/[name].js', | ||
library: { type: 'umd' }, | ||
path: resolve(__dirname, './public'), | ||
publicPath: '/' | ||
}, | ||
|
||
plugins: [ | ||
new CopyPlugin({ | ||
patterns: [ | ||
resolve(__dirname, 'index.html'), | ||
{ | ||
context: resolve(frontendPath, './assets'), | ||
from: '{fonts,images}/**', | ||
to: './assets' | ||
}, | ||
{ | ||
context: html5shivPath, | ||
from: 'html5shiv.min.js', | ||
to: './assets/javascripts' | ||
} | ||
] | ||
}), | ||
new CleanWebpackPlugin({ | ||
cleanOnceBeforeBuildPatterns: ['**/*', '!**/{fonts,images}/**'] | ||
}) | ||
], | ||
|
||
stats: { | ||
preset: 'minimal', | ||
errorDetails: true | ||
}, | ||
|
||
module.exports = config | ||
resolve: { modules: [modulesPath] }, | ||
target: ['web', 'es5'] | ||
}) |
Oops, something went wrong.