File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed
Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,8 @@ Webpack configuration that creates a sfmc compatible script.
66 * array functions (map, reduce, forEach)
77 * Object functions (keys)
88* modern JS syntax
9- * ampScript loader
9+ * ampScriptLoader
10+ * htmlLoader
1011* minification (optionally)
1112## Installation
1213` git clone https://github.com/adessoSE/ssjs-webpack.git `
@@ -51,6 +52,27 @@ in `/src/index.js`:
5152```
5253import ampFile from './lib/foo.amp'
5354Write(ampFile.run());
55+ ```
56+ ### htmlLoader
57+ external html files can be imported and displayed.
58+ > ** _ NOTE:_ ** do not overwrite the ` /templates/index.ejs ` . It is required to build the SFMC compatible script.
59+ Example:
60+ create a new file ` /templates/index.html ` :
61+ ```
62+ <html>
63+ <head>
64+ <title>Hello World!</title>
65+ </head>
66+ <body>
67+ <h1 name="msg">Hello World!</h1>
68+ </body>
69+ </html>
70+ ```
71+ in ` /src/index.js ` :
72+ ```
73+ import index from 'templates/index.html';
74+ index.display();
75+
5476```
5577### minification
5678By default minification is disabled. To enable it, go to ` \webpack.config.js ` and set
Original file line number Diff line number Diff line change 1+ module . exports = ( input ) => {
2+ return `export default({
3+ display: function(){Write(TreatAsContent('${ input . replace ( / \> [ \r \n ] + \< / g, "><" )
4+ . replace ( / ( < .* ?> ) | \s + / g, ( m , $1 ) => $1 ? $1 : ' ' )
5+ . replace ( / ' / gi, "\\'" )
6+ . trim ( ) } '))}
7+ })` ;
8+ } ;
Original file line number Diff line number Diff line change @@ -25,6 +25,16 @@ module.exports = {
2525 target : [ "web" , "es3" ] ,
2626 module : {
2727 rules : [
28+ {
29+ test : / \. ( h t m l ) $ / ,
30+ exclude : / n o d e _ m o d u l e s / ,
31+ use : [
32+ {
33+ loader : "./loaders/htmlLoader.js" ,
34+ options : { } ,
35+ } ,
36+ ] ,
37+ } ,
2838 {
2939 test : / \. ( j s ) $ / ,
3040 exclude : / n o d e _ m o d u l e s / ,
@@ -58,6 +68,7 @@ module.exports = {
5868 alias : {
5969 polyfills : path . resolve ( __dirname , "polyfills/" ) ,
6070 lib : path . resolve ( __dirname , "lib/" ) ,
71+ templates : path . resolve ( __dirname , "templates/" )
6172 } ,
6273 } ,
6374} ;
You can’t perform that action at this time.
0 commit comments