Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
app
bin
config
lib
log
public
tmp
vendor
.gitignore
Gemfile
Gemfile.lock
README.md
Rakefile
config.ru
package-lock.json
package.json
webpack.config.js

README.md

Simpacker asset-host example

To deliver assets from CDN or S3, you will set config.action_controller.asset_host in Rails configuration.

In Simpacker, this setting is used for javascript_pack_tag and stylesheet_pack_tag, but this setting is not used for URLs embedded in JavaScript or CSS using file-loader. In such cases, you need to set the publicPath of the webpack.

   },
   output: {
     path: path.resolve(__dirname, "public/packs"),
-    publicPath: "/packs/",
+    publicPath: isProd ? "https://cdn.example.com/packs/" : "/packs/",
     filename: isProd ? "[name]-[hash].js" : "[name].js"
   },
   resolve: {
     extensions: [".js"]
   },
+  module: {
+    rules: [
+      {
+        test: /\.(png|jpg|gif|ttf|eot|woff|woff2|svg)$/,
+        use: "file-loader"
+      }
+    ]
+  },
   plugins: [new WebpackAssetsManifest({ publicPath: true })]
 };
You can’t perform that action at this time.