EDIT:I need to directly generate <script type="text/javascript" src="..."></script>
format to a text file which my web app(django or rails) template engine can directly include. So a json file seems not ok.
After webpack update the js file in webpack --progress --colors --watch
mode, I want to :
- Create a copy with hashed-filename to specified path.
- execute some nodejs code that lists all filenames in specified directory and writes them to a text file.
Currently my config file is:
module.exports = {
entry: "./index.js",
output: {
path: __dirname,
filename: "bundle.[hash].js"
},
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" },
{ test: /\.scss$/, loaders: ["style", "css", "sass"]},
],
}
};
For example, every time webpack generate a bundle.[hash].js
file, it will first make its copy to /bar
, then check all filenames in /bar
and write these filenames to /foo/bar/js.txt
in this format:
<script type="text/javascript" src="/bar/bundle.sdfklsld.js"></script>
<script type="text/javascript" src="/bar/bundle.jkljsdfd.js"></script>
I know this maybe done by bundle-update, but it's poorly documented.