Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rupurt/webpack-copy-after-build-plugin
Copy files from a Webpack build
https://github.com/rupurt/webpack-copy-after-build-plugin
Last synced: 21 days ago
JSON representation
Copy files from a Webpack build
- Host: GitHub
- URL: https://github.com/rupurt/webpack-copy-after-build-plugin
- Owner: rupurt
- License: mit
- Created: 2016-09-07T20:39:29.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-05T15:34:23.000Z (over 6 years ago)
- Last Synced: 2024-10-10T14:38:30.484Z (about 1 month ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 4
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Webpack Copy After Build Plugin
===============================A webpack plugin that allows webpack build artifacts to be included via sprockets
directives. This helps reduce the onboarding time and friction when introducing
Webpack into a legacy Rails application.Install
-------```bash
npm install webpack-copy-after-build-plugin --save
```Configuration
-------------Create a directory in the asset pipeline which will receive copied build files e.g.
```
mkdir -p app/assets/javascripts/generated
```Configure the plugin to copy the required bundles into the asset pipeline
```javascript
// client/webpack.config.js
var path = require("path");
var WebpackSprocketsRailsManifestPlugin = require("webpack-sprockets-rails-manifest-plugin");var config = {
context: __dirname,entry: {
"webpack-application-bundle": "./bundles/webpack-application"
},output: {
path: path.resolve(__dirname, "../public/assets"),
filename: "[name]-[chunkhash].js"
},// Other config ...
plugins: [
new WebpackSprocketsRailsManifestPlugin(),new WebpackCopyAfterBuildPlugin({
"webpack-application-bundle":
"../../app/assets/javascripts/generated/webpack-application-bundle.js",
})
]
};
``````javascript
// client/bundles/webpack-application.js
alert("Howdy, I'm a Webpack Javascript file that was required by a sprockets directive!");
```Require the build artifact via a sprockets directive
```javascript
// app/assets/javascripts/application.js
//= require ./generated/webpack-application-bundle
```Options and Defaults
---------------------```javascript
{
// The path that you give as the destination will be taken as absolute if this flag is set
absoluteMappingPaths : false
}
```