An open API service indexing awesome lists of open source software.

https://github.com/jamesnuttall/injecttwigwebpackplugin

Webpack plugin to inject twig js/css register syntax.
https://github.com/jamesnuttall/injecttwigwebpackplugin

css html injects javacript twig webpack webpack-plugin

Last synced: 24 days ago
JSON representation

Webpack plugin to inject twig js/css register syntax.

Awesome Lists containing this project

README

        

inject-twig-webpack-plugin
===

[![NPM](https://nodei.co/npm/inject-twig-webpack-plugin.png)](https://nodei.co/npm/inject-twig-webpack-plugin/)

based off [inject-html-webpack-plugin](https://github.com/ali322/inject-html-webpack-plugin). Takes js/css files and using the twig `view.register` syntax, injects the files.

Install
===

```javascript
npm install inject-twig-webpack-plugin --save--dev
```

Usage
===

add plugin in your webpack.config.js

```javascript
var InjectTwigPlugin = require('inject-twig-webpack-plugin');

module.exports = {
entry:{
index:"./index.js"
},
module:{
loaders:[
...
]
},
output:{
path:'./dist',
filename:'[name].min.js'
},
plugins:[
new InjectTwigPlugin({
transducer: function (filename) {
return "/assets/js/vue/dist/"+filename;
},
filename: '../../../../templates/_layout/_footer.html',
chunks:['index']
})
]
}
```

then add below placeholders into html file

```html


Document


```

Output
===

```

{% do view.registerJsFile(siteUrl ~ "/assets/js/vue/dist/index.c38144da9d3ebd917778.js") %}

```

## License

[MIT License](http://en.wikipedia.org/wiki/MIT_License)