Skip to content

Commit

Permalink
feat: add babel and postcss configs to templates
Browse files Browse the repository at this point in the history
  • Loading branch information
KonnorRogers committed Jul 26, 2020
1 parent 588b41f commit a0b0ec4
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 280 deletions.
228 changes: 0 additions & 228 deletions examples/railsapp/Gemfile.lock

This file was deleted.

52 changes: 0 additions & 52 deletions lib/snowpacker/runner.rb

This file was deleted.

72 changes: 72 additions & 0 deletions lib/snowpacker/templates/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
module.exports = function() {
const validEnv = ['development', 'test', 'production']
const currentEnv = process.env["NODE_ENV"]
const isDevelopmentEnv = (currentEnv === "development")
const isProductionEnv = (currentEnv === 'production')
const isTestEnv = (currentEnv === 'test')

if (!validEnv.includes(currentEnv)) {
throw new Error(
'Please specify a valid `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(currentEnv) +
'.'
)
}

return {
presets: [
isTestEnv && [
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
],
(isProductionEnv || isDevelopmentEnv) && [
'@babel/preset-env',
{
forceAllTransforms: true,
useBuiltIns: 'entry',
corejs: 3,
modules: false,
exclude: ['transform-typeof-symbol']
}
]
].filter(Boolean),
plugins: [
'babel-plugin-macros',
'@babel/plugin-syntax-dynamic-import',
isTestEnv && 'babel-plugin-dynamic-import-node',
'@babel/plugin-transform-destructuring',
[
'@babel/plugin-proposal-class-properties',
{
loose: true
}
],
[
'@babel/plugin-proposal-object-rest-spread',
{
useBuiltIns: true
}
],
[
'@babel/plugin-transform-runtime',
{
helpers: false,
regenerator: true,
corejs: false
}
],
[
'@babel/plugin-transform-regenerator',
{
async: false
}
]
].filter(Boolean)
}
}
12 changes: 12 additions & 0 deletions lib/snowpacker/templates/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
plugins: [
require('postcss-import'),
require('postcss-flexbugs-fixes'),
require('postcss-preset-env')({
autoprefixer: {
flexbox: 'no-2009'
},
stage: 3
})
]
}

0 comments on commit a0b0ec4

Please sign in to comment.