Read the statement by Michael Teeuw here.
MMM-Tabulator: How to port HTML JS imports to node JS imports? [solved]
-
From here:
If the "nosniff" directive is received on a response received by a styleSheet reference, Windows Internet Explorer will not load the "stylesheet" file unless the MIME type matches "text/css". If the "nosniff" directive is received on a response retrieved by a script reference, Internet Explorer will not load the "script" file unless the MIME type matches one of the following values:
How do yo pass the correct MIME type in the MMM relevant node.js language?
-
Is there really nobody who knows how to import a CSS stylesheet from a
./node_modules/
installed package?The package(s) in question are
jquery
,jquery-ui
, and were installed with:npm install jquery --save
in my module directory. -
@E3V3A I don’t know whether that helps but you need to write
this.file("node_modules/jquery-ui-dist/jquery-ui.min.js")
in yourgetStyles
andgetScripts
functions. -
@raywo Hi! Yeah, that worked! Thank you! I was going really crazy here…
Anything other than what’s shown below, results in an error as mentioned above.
Apparently the only types of paths that work, are the following (including the out-commented ones):getScripts: function() { // return ["moment.js"]; return [ this.file('node_modules/jquery/dist/jquery.min.js'), this.file('node_modules/jquery-ui-dist/jquery-ui.min.js'), this.file('node_modules/jquery.tabulator/dist/js/tabulator.js') // 'modules/MMM-Tabulator/node_modules/jquery/dist/jquery.min.js', // 'modules/MMM-Tabulator/node_modules/jquery-ui-dist/jquery-ui.min.js', // 'modules/MMM-Tabulator/node_modules/jquery.tabulator/dist/js/tabulator.js' ] }, getStyles: function() { return [ this.file('node_modules/jquery-ui-dist/jquery-ui.css'), this.file('node_modules/jquery.tabulator/dist/css/tabulator.css'), "MMM-Tabulator.css" ]; },
That took considerable trial-and-error, as this is not at all apparent from the documentation. At least not how I interpret it. (I was clearly under the incredibly naive impression that MM would search the file tree in
node_modules
directory and elsewhere, looking for the file names specified.) -
@E3V3A These paths are relative to your module file, which is why
this.file()
is needed.I believe you could have alternately start with a slash, which makes the path relative to the server root:
'/modules/MMM-Tabulator/node_modules/jquery/dist/jquery.min.js', '/modules/MMM-Tabulator/node_modules/jquery-ui-dist/jquery-ui.min.js', '/modules/MMM-Tabulator/node_modules/jquery.tabulator/dist/js/tabulator.js'
-
@ninjabreadman Thank you very much for trying to help. But I’m pretty sure I tried that as well…at some point, giving me a “double” path. (Perhaps a browser cache issue?).
Anyway, this is resolved, and I have a new problem of a completely different sort in this thread.