Skip to content

Commit

Permalink
Merge pull request #8 from leviy/master_require_twigjs-loader
Browse files Browse the repository at this point in the history
Use twigjs-loader instead of twig-loader
  • Loading branch information
denniscoorn authored Oct 17, 2019
2 parents adeec2d + 586734e commit 89d81c1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/.idea/
/node_modules/
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@leviy/webpack-config-default",
"version": "3.0.1",
"version": "3.1.0",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com:leviy/webpack-config-default.git"
Expand All @@ -14,7 +14,7 @@
"mini-css-extract-plugin": "^0.8",
"postcss-loader": "^3.0",
"sass-loader": "^7.1",
"twig-loader": "^0.5",
"twigjs-loader": "^1.0",
"webpack-config": "^7.5",
"webpack-manifest-plugin": "^2.0"
},
Expand Down
13 changes: 12 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { Config, environment } = require('webpack-config');

const path = require('path');
const webpack = require('webpack');

const ManifestPlugin = require('webpack-manifest-plugin');
Expand Down Expand Up @@ -30,7 +31,17 @@ module.exports = new Config().defaults({
rules: [
{
test: /\.twig$/,
loader: 'twig-loader',
loader: 'twigjs-loader',
options: {
renderTemplate(twigData, dependencies) {
return `
${dependencies}
var twig = require('${path.resolve(process.cwd(), 'node_modules/twig')}').twig;
var tpl = twig(${JSON.stringify(twigData)});
module.exports = function(context) { return tpl.render(context); };
`;
},
},
},
{
test: /\.js$/,
Expand Down

0 comments on commit 89d81c1

Please sign in to comment.