Skip to content

Instantly share code, notes, and snippets.

@scotteknight
Last active July 15, 2019 16:33
Show Gist options
  • Save scotteknight/42cdeb4cf0e2909231bb3d57efd6c28e to your computer and use it in GitHub Desktop.
Save scotteknight/42cdeb4cf0e2909231bb3d57efd6c28e to your computer and use it in GitHub Desktop.
Webpacker Config Files 7/10/19
const { environment } = require("@rails/webpacker");
const webpack = require("webpack");
// remove when fixed https://github.com/rails/webpacker/issues/2003
const merge = require("webpack-merge");
const sassLoader = environment.loaders.get("sass");
const cssLoader = environment.loaders.get("css");
sassLoader.use.map(function(loader) {
if (loader.loader === "css-loader") {
loader.options = merge(loader.options, { sourceMap: false });
}
});
cssLoader.use.map(function(loader) {
if (loader.loader === "css-loader") {
loader.options = merge(loader.options, { sourceMap: false });
}
});
// remove when fixed https://github.com/rails/webpacker/issues/2003
environment.plugins.append(
"Provide",
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
Popper: ["popper.js", "default"]
})
);
module.exports = environment;
{
"name": "scotteknight",
"private": true,
"dependencies": {
"@rails/webpacker": "4.0.7",
"@uppy/aws-s3": "^1.1.0",
"@uppy/core": "^1.1.0",
"bootstrap": "^4.3.1",
"dayjs": "1.8.15",
"flexbin": "^0.2.0",
"font-awesome": "^4.7.0",
"jquery": "3.4.1",
"popper.js": "^1.15.0",
"rails-ujs": "^5.2.3",
"stimulus": "^1.1.1",
"stimulus-flatpickr": "^1.0.0",
"tablesort": "^5.1.0",
"turbolinks": "^5.2.0",
"webpack-merge": "^4.2.1",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
"webpack-bundle-analyzer": "^3.3.2",
"webpack-dev-server": "^3.3.1"
}
}
module.exports = {
plugins: [
require('postcss-import'),
require('postcss-flexbugs-fixes'),
require('postcss-preset-env')({
autoprefixer: {
flexbox: 'no-2009'
},
stage: 3
})
]
}
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
const environment = require('./environment')
module.exports = environment.toWebpackConfig()
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
source_path: app/javascript
source_entry_path: packs
public_root_path: public
public_output_path: packs
cache_path: tmp/cache/webpacker
check_yarn_integrity: false
webpack_compile_output: false
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: []
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
# Extract and emit a css file
extract_css: false
static_assets_extensions:
- .jpg
- .jpeg
- .png
- .gif
- .tiff
- .ico
- .svg
- .eot
- .otf
- .ttf
- .woff
- .woff2
extensions:
- .mjs
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
development:
<<: *default
compile: true
# Verifies that versions and hashed value of the package contents in the project's package.json
check_yarn_integrity: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: false
# Inline should be set to true if using HMR
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: '**/node_modules/**'
test:
<<: *default
compile: true
# Compile test packs to a separate directory
public_output_path: packs-test
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Extract and emit a css file
extract_css: true
# Cache manifest.json for performance
cache_manifest: true
@jakeNiemiec
Copy link

I don't see anything wrong here 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment