-
-
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.
fix(config): fix issue with configuration.rb, generate config
- Loading branch information
1 parent
ba62564
commit 3d6a8f1
Showing
5 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
examples/rails-without-webpack/config/snowpacker/.browserslistrc
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 @@ | ||
defaults |
72 changes: 72 additions & 0 deletions
72
examples/rails-without-webpack/config/snowpacker/babel.config.js
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,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
12
examples/rails-without-webpack/config/snowpacker/postcss.config.js
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,12 @@ | ||
module.exports = { | ||
plugins: [ | ||
require('postcss-import'), | ||
require('postcss-flexbugs-fixes'), | ||
require('postcss-preset-env')({ | ||
autoprefixer: { | ||
flexbox: 'no-2009' | ||
}, | ||
stage: 3 | ||
}) | ||
] | ||
} |
42 changes: 42 additions & 0 deletions
42
examples/rails-without-webpack/config/snowpacker/snowpack.config.js
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,42 @@ | ||
const output_path = process.env["SNOWPACKER_OUTPUT_PATH"] | ||
const port = process.env["SNOWPACKER_PORT"] | ||
const mount_dir = process.env["SNOWPACKER_MOUNT_DIR"] | ||
const babel_config = process.env["SNOWPACKER_BABEL_CONFIG_FILE"] | ||
const postcss_config = process.env["SNOWPACKER_POSTCSS_CONFIG_FILE"] | ||
|
||
// not currently supported | ||
// const hostname = process.env["SNOWPACKER_HOSTNAME"] | ||
|
||
const scripts = { | ||
"mount:web_modules": `mount web_modules --to /${output_path}`, | ||
"mount:__snowpack__": `mount __snowpack__ --to /${output_path}`, | ||
"mount:snowpacks": `mount ${mount_dir} --to /${output_path}`, | ||
"build:css": `postcss --config ${postcss_config}`, | ||
"build:js,jsx,ts,tsx": `babel --config-file ${babel_config} \ | ||
--out-dir ${process.cwd()} \ | ||
${mount_dir}` | ||
} | ||
|
||
const installOptions = { | ||
NODE_ENV: true | ||
} | ||
|
||
const devOptions = { | ||
port: parseInt(port, 10), | ||
open: "none", | ||
out: "public" | ||
} | ||
|
||
const buildOptions = { | ||
clean: true, | ||
baseUrl: "/" | ||
} | ||
|
||
module.exports = { | ||
scripts, | ||
plugins: ["@snowpack/babel-plugin-package-import"], | ||
installOptions, | ||
devOptions, | ||
buildOptions | ||
} | ||
|
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