Closed karayeltasarim closed 6 years ago
Hi @karayeltasarim,
No need for RequireJS.
If you are using ampify
with Node/Express, just create a package.json
:
{
"name": "ampify-example",
"main": "index.js",
"dependencies": {
"ampify": "^0.2.6",
"express": "^4.16.1"
}
}
Install dependencies:
npm install
Create a simple HTTP server in index.js
:
const ampify = require('ampify');
const express = require('express');
const app = express();
app.get('/', function (req, res) {
const html = `
<html>
<head>
<title>AMP page</title>
</head>
<body>
<div>
<p>This is text</p>
</div>
</body>
</html>
`;
const amp = ampify(html, {cwd: 'amp'});
res.send(amp); // Serving AMP HTML
});
app.listen(3000, function () {
console.log('Listening on port 3000!');
});
Run the server and see AMP HTML at http://localhost:3000/:
node index.js
Please see more examples here: https://github.com/rkazakov/ampify/tree/master/examples
Hi, it seems like you are doing a great work. I really like what i see but i couldn't make it work.
After i have downloaded the ampify, i have tried to work it as is, but it says require is not defined, so i assume that it needs require.js too.
After installing the require.js i have moved your index.js file to lib subfolder of the main directory and renamed it as ampify.js. Right after i have write your javascript sample to main.js as is:
Still i am getting the following error:
Any help would be amazing. Keep up the great work.