-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #281 from CityOfDetroit/issue.278
Create stable build pipeline for UXDS
- Loading branch information
Showing
12 changed files
with
197 additions
and
152 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,19 @@ | ||
name: 'Package Build Tests' | ||
on: | ||
push: | ||
branches: [ dev ] | ||
pull_request: | ||
branches: [ dev ] | ||
jobs: | ||
package-build-tests: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/Jod | ||
- name: Install dependencies | ||
run: yarn | ||
- name: Build package using Webpack | ||
run: yarn build |
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
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 |
---|---|---|
|
@@ -111,3 +111,6 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Storybook static build files | ||
storybook-static/ |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 @@ | ||
<head><script defer="defer" src="assets/js/runtime.js"></script><script defer="defer" src="assets/js/main.js"></script></head><script src="index.js"></script> |
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
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,150 @@ | ||
const path = require('path'); | ||
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const webpack = require('webpack'); | ||
const TerserWebpackPlugin = require('terser-webpack-plugin'); | ||
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); | ||
|
||
const createConfig = (options) => { | ||
const { entry, outputPath, port = 3000 } = options; | ||
return (_env, argv) => { | ||
const isProduction = argv.mode === 'production'; | ||
const isDevelopment = !isProduction; | ||
|
||
return { | ||
devtool: isDevelopment && 'cheap-module-source-map', | ||
entry, | ||
output: { | ||
path: path.resolve(__dirname, outputPath), | ||
filename: 'assets/js/[name].js', | ||
publicPath: '', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.jsx?$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
cacheDirectory: true, | ||
cacheCompression: false, | ||
envName: isProduction ? 'production' : 'development', | ||
}, | ||
}, | ||
}, | ||
{ | ||
test: /\.css$/i, | ||
use: [ | ||
isProduction ? MiniCssExtractPlugin.loader : 'to-string-loader', | ||
'css-loader', | ||
'postcss-loader', | ||
], | ||
}, | ||
{ | ||
test: /\.s[ac]ss$/i, | ||
use: [ | ||
isProduction ? MiniCssExtractPlugin.loader : 'style-loader', | ||
'css-loader', | ||
'sass-loader', | ||
], | ||
}, | ||
{ | ||
test: /\.(png|jpg|gif)$/i, | ||
use: { | ||
loader: 'url-loader', | ||
options: { | ||
limit: 8192, | ||
name: 'static/media/[name].[hash:8].[ext]', | ||
}, | ||
}, | ||
}, | ||
{ | ||
test: /\.svg$/, | ||
use: ['@svgr/webpack'], | ||
}, | ||
{ | ||
test: /\.(eot|otf|ttf|woff|woff2)$/, | ||
loader: require.resolve('file-loader'), | ||
options: { | ||
name: 'static/media/[name].[hash:8].[ext]', | ||
}, | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.js', '.jsx'], | ||
}, | ||
plugins: [ | ||
isProduction && | ||
new MiniCssExtractPlugin({ | ||
filename: 'assets/css/[name].css', | ||
chunkFilename: 'assets/css/[name].chunk.css', | ||
}), | ||
new HtmlWebpackPlugin({ | ||
template: path.resolve(__dirname, 'public/index.html'), | ||
inject: true, | ||
}), | ||
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify( | ||
isProduction ? 'production' : 'development', | ||
), | ||
}), | ||
].filter(Boolean), | ||
optimization: { | ||
minimize: isProduction, | ||
minimizer: [ | ||
new TerserWebpackPlugin({ | ||
terserOptions: { | ||
compress: { | ||
comparisons: false, | ||
}, | ||
mangle: { | ||
safari10: true, | ||
}, | ||
output: { | ||
comments: false, | ||
ascii_only: true, | ||
}, | ||
warnings: false, | ||
}, | ||
}), | ||
new CssMinimizerPlugin(), | ||
], | ||
splitChunks: { | ||
chunks: 'all', | ||
minSize: 0, | ||
maxInitialRequests: 10, | ||
maxAsyncRequests: 10, | ||
cacheGroups: { | ||
vendors: { | ||
test: /[\\/]node_modules[\\/]/, | ||
name(module, chunks, cacheGroupKey) { | ||
const packageName = module.context.match( | ||
/[\\/]node_modules[\\/](.*?)([\\/]|$)/, | ||
)[1]; | ||
return `${cacheGroupKey}.${packageName.replace('@', '')}`; | ||
}, | ||
}, | ||
common: { | ||
minChunks: 2, | ||
priority: -10, | ||
}, | ||
}, | ||
}, | ||
runtimeChunk: 'single', | ||
}, | ||
devServer: { | ||
port, | ||
compress: true, | ||
historyApiFallback: true, | ||
open: true, | ||
client: { | ||
overlay: true, | ||
}, | ||
}, | ||
}; | ||
}; | ||
}; | ||
|
||
module.exports = createConfig; |
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 @@ | ||
const createConfig = require('./webpack.common'); | ||
|
||
module.exports = createConfig({ | ||
entry: './src/experimental/index-experimental.js', | ||
outputPath: 'build/experimental', | ||
port: 3000 | ||
}); |
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,7 @@ | ||
const createConfig = require('./webpack.common'); | ||
|
||
module.exports = createConfig({ | ||
entry: './src/stable/index-stable.js', | ||
outputPath: 'build/stable', | ||
port: 3001 | ||
}); |