",
19 | "license": "MIT",
20 | "homepage": "https://github.com/sap9433/filewatcher-webpack-plugin",
21 | "devDependencies": {
22 | "chai": "^4.2.0",
23 | "mocha": "^6.0.2",
24 | "path": "^0.12.7",
25 | "jsx-loader": "^0.13.2",
26 | "node-async-require-loader": "^2.0.0",
27 | "node-fetch": "^2.3.0",
28 | "react": "^16.8.6",
29 | "webpack": "^4.29.6",
30 | "webpack-dev-server": "^3.2.1"
31 | },
32 | "dependencies": {
33 | "chokidar": "^2.1.5"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/test/fixtures/components/local-hello-world.rt:
--------------------------------------------------------------------------------
1 | Hello World From Austin
--------------------------------------------------------------------------------
/test/fixtures/components/remote-hello-world.ajs:
--------------------------------------------------------------------------------
1 | module.exports={
2 | remoteUrl:"https://jaydenlin.github.io/fake-remote-contents-for-test/contents/react-template/",
3 | localPath:"./test/fixtures/components/local-hello-world.rt"
4 | }
--------------------------------------------------------------------------------
/test/fixtures/components/remote-hello-world.jsx:
--------------------------------------------------------------------------------
1 | var React = require('React');
2 | // var helloTemplate = require("./local-hello-world.rt");
3 | var helloTemplate = require("./remote-hello-world.ajs");
4 | var Hello = React.createClass({
5 |
6 | render: function() {
7 | return helloTemplate.apply(this);
8 | }
9 |
10 | });
11 |
12 | module.exports = Hello;
--------------------------------------------------------------------------------
/test/fixtures/index.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/fixtures/index.jsx:
--------------------------------------------------------------------------------
1 | var React=require("React");
2 | var Root=require("./components/remote-hello-world.jsx");
3 | React.render(,document.getElementById("root"));
--------------------------------------------------------------------------------
/test/test.js:
--------------------------------------------------------------------------------
1 | var chai = require('chai');
2 | var webpack = require("webpack");
3 | var webpackDevServer = require("webpack-dev-server");
4 | var config = require("./webpack.config.js");
5 | var expect = chai.expect;
6 | var fs = require("fs");
7 | var path = require("path");
8 | var fetch = require('node-fetch');
9 |
10 |
11 | describe('watchFile-webpack-plugin', function(){
12 |
13 | it('Change rt file content, webDevServer should hash code should change.', function(done){
14 | this.timeout(50000);
15 | fs.writeFileSync(path.join(__dirname, "/fixtures/components/local-hello-world.rt"), "Hello World From Local...!{this.props.name}
");
16 | var compiler = webpack(config);
17 | var server = new webpackDevServer(compiler);
18 | server.listen(1024);
19 | fs.writeFileSync(path.join(__dirname, "/fixtures/components/local-hello-world.rt"), "Hello World From Austin
");
20 | fetch('http://localhost:1024/js/index.js')
21 | .then(function(res) {
22 | return res.text();
23 | }).then(function(body) {
24 | expect(body.indexOf("Hello World From Austin")).to.not.equal(-1);
25 | done();
26 | });
27 | });
28 |
29 | });
--------------------------------------------------------------------------------
/test/webpack.config.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var path = require("path"),
3 | webpack = require("webpack"),
4 | watchFilePlugin = require("../index.js");
5 | module.exports = {
6 | mode: 'development',
7 | cache: true,
8 | entry: {
9 | index: path.join(__dirname,"./fixtures/index.jsx")
10 | },
11 | output: {
12 | path: path.join(__dirname, 'dist'),
13 | publicPath: "/",
14 | filename: 'js/[name].js'
15 | },
16 | module: {
17 | rules:[
18 | {
19 | test: /\.ajs$/,
20 | loader: ["node-async-require-loader?preParser=rt&async=false"]
21 | },
22 | {
23 | test: /\.jsx$/,
24 | loader: ["jsx-loader?insertPragma=React.DOM&harmony"]
25 | }
26 | ]
27 | },
28 | plugins: [
29 | new watchFilePlugin({watchFolder: path.join(__dirname ,"/fixtures/components/"), watchExtension: "rt"})
30 | ],
31 | externals: {
32 |
33 | },
34 | resolve: {
35 | extensions: ['.js', '.jsx', '.ajs', '.html'],
36 | alias: {"React": path.join(__dirname,"../node_modules/react/index.js")}
37 | }
38 | };
--------------------------------------------------------------------------------
/with-great-power-comes-great-responsibility-spider-man-super-powers-abilities-voltaire-quote.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sap9433/filewatcher-webpack-plugin/37be4fd21df2a38c6197a9d46e115983c525b31c/with-great-power-comes-great-responsibility-spider-man-super-powers-abilities-voltaire-quote.jpg
--------------------------------------------------------------------------------