Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates v3 #2

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GOOGLEMAPS_TOKEN=
MAPBOX_TOKEN=
JAWG_TOKEN=
5 changes: 0 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,3 @@ jobs:
uses: yoriiis/actions/.github/workflows/test-and-build.yml@main
with:
node-version: 18
setup-python: true
command-build: |
make install
npm run build
make build
6 changes: 1 addition & 5 deletions .github/workflows/github-pages-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@ jobs:
uses: yoriiis/actions/.github/workflows/github-pages-deploy.yml@main
with:
node-version: 18
command-build: |
make install
npm run build
make build
build-dir: site
build-dir: dist
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
uses: yoriiis/actions/.github/workflows/lint.yml@main
with:
typescript-status: false
stylelint-status: false
markdown-status: false
publint-status: false
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
site
docs/demo
node_modules
credentials.json
.env
dist
10 changes: 0 additions & 10 deletions Makefile

This file was deleted.

37 changes: 37 additions & 0 deletions config/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const fs = require('fs')
const path = require('path')
require('dotenv').config({ path: path.resolve(__dirname, '../.env') })

let googleMapsToken = process.env.GOOGLEMAPS_TOKEN
let mapBoxToken = process.env.MAPBOX_TOKEN
let jawgToken = process.env.JAWG_TOKEN

if (process.env.CI) {
googleMapsToken = 'xxxx'
mapBoxToken = 'xxxx'
jawgToken = 'xxxx'
}

if (googleMapsToken && mapBoxToken && jawgToken) {
const data = JSON.stringify(
{
GOOGLEMAPS_TOKEN: process.env.GOOGLEMAPS_TOKEN,
MAPBOX_TOKEN: process.env.MAPBOX_TOKEN,
JAWG_TOKEN: process.env.JAWG_TOKEN
},
null,
'\t'
)

fs.writeFile(path.resolve(__dirname, '../credentials.json'), data, 'utf8', (err) => {
if (err) {
console.error('An error occured when creating credentials file', err)
} else {
console.log('Credentials file created')
}
})
} else {
throw new Error(
'Environments variables are missing in .env ("GOOGLEMAPS_TOKEN", "MAPBOX_TOKEN", "JAWG_TOKEN")'
)
}
49 changes: 35 additions & 14 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,26 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')

const appDirectory = fs.realpathSync(process.cwd())
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath)

module.exports = (env, argv) => {
const isProduction = argv.mode === 'production'

const config = {
return {
context: appDirectory,
entry: {
demo: resolveApp('src/demo/config.js')
demo: resolveApp('src/demo/config.js'),
validate: resolveApp('src/validate/config.js')
},
watchOptions: {
ignored: /node_modules/
},
devtool: isProduction ? false : 'source-map',
output: {
path: resolveApp('docs/demo'),
path: resolveApp('dist'),
filename: 'scripts/[name].js',
clean: true
},
Expand All @@ -39,7 +41,11 @@ module.exports = (env, argv) => {
},
{
test: /\.css$/,
include: [resolveApp('src'), resolveApp('node_modules/storelocatorjs')],
include: [
resolveApp('src'),
resolveApp('node_modules/storelocatorjs'),
resolveApp('../storelocatorjs')
],
use: [
MiniCssExtractPlugin.loader,
{
Expand All @@ -63,7 +69,11 @@ module.exports = (env, argv) => {
]
},
resolve: {
extensions: ['.js', '.css']
extensions: ['.js', '.css'],
alias: {
shared: resolveApp('/src/shared'),
package: resolveApp('../storelocatorjs')
}
},
devServer: {
static: {
Expand All @@ -73,18 +83,35 @@ module.exports = (env, argv) => {
port: 3000,
compress: true,
hot: true
// open: true
},
plugins: [
new webpack.ProgressPlugin(),
new MiniCssExtractPlugin({
filename: 'styles/[name].css',
chunkFilename: 'styles/[name].css'
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: resolveApp('src/demo/index.html')
template: resolveApp('public/index.html'),
chunks: ['demo']
}),
new webpack.optimize.ModuleConcatenationPlugin()
new HtmlWebpackPlugin({
filename: 'validate.html',
template: resolveApp('public/validate.html'),
chunks: ['validate']
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new CopyPlugin({
patterns: [
{
from: resolveApp('public'),
to: resolveApp('dist'),
globOptions: {
ignore: ['**/*.html']
}
}
]
})
],
stats: {
assets: true,
Expand Down Expand Up @@ -123,10 +150,4 @@ module.exports = (env, argv) => {
splitChunks: false
}
}

if (!isProduction) {
config.plugins.push(new webpack.ProgressPlugin())
}

return config
}
1 change: 0 additions & 1 deletion docs/CNAME

This file was deleted.

Loading