简体   繁体   中英

webpack starting but not watching for changes?

I have a repo set up for a project which is using webpack and works perfectly. I copied the entire repo to start a new project. Now when I run "npm run watch" webpack starts but will not watch for changes. my package.json file looks like this:

    {
  "name": "donedone-api",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "watch": "webpack --progress --colors --watch",
    "build": "webpack --progress --colors",
    "deploy": "NODE_ENV=production webpack -p --progress --colors"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-loader": "^6.2.4",
    "babel-polyfill": "^6.5.0",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-react": "^6.5.0",
    "base-64": "^0.1.0",
    "imagesloaded": "^4.1.0",
    "imports-loader": "^0.6.5",
    "react": "^15.1.0",
    "react-dom": "^15.1.0"
  },
  "devDependencies": {
    "babel-core": "^6.5.1",
    "babel-loader": "^6.2.2",
    "babel-polyfill": "^6.5.0",
    "babel-preset-es2015": "^6.5.0",
    "browser-sync": "^2.11.1",
    "browser-sync-webpack-plugin": "^1.0.1",
    "clean-webpack-plugin": "^0.1.8",
    "css-loader": "^0.23.1",
    "extract-text-webpack-plugin": "^1.0.1",
    "file-loader": "^0.8.5",
    "img-loader": "^1.1.2",
    "node-sass": "^3.4.2",
    "sass-loader": "^3.1.2",
    "style-loader": "^0.13.0",
    "url-loader": "^0.5.7",
    "webpack": "^1.13.1"
  }
}

and my webpack config like this:

var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

require('webpack/lib/ResolverPlugin');



// const webRoot         = './site/'
// const assetsPath      = path.join(webRoot, 'assets')
// const srcDir          = path.resolve(__dirname, 'src')
// const srcAssetsPath   = path.join(srcDir, 'assets')
// const spritePath      = path.join(srcAssetsPath, 'sprites')

var config = {
  entry: './src/js/main',
  externals: {
    'jquery': '$'
  },
  output: {
    path: './site/assets',
    filename: 'main.js'
  },
  module : {
    loaders : [
      {
        test : /\.js?/,
        loader : 'babel'
      },
      {
        test: /\.scss$/,
        loader: ExtractTextPlugin.extract('css!sass')
       },
     {
      test: /\.(jpe?g|png|gif|svg)$/i,
      loader: 'url?limit=25000!img?progressive=true'
     },
     {
        test: /\.(eot|svg|ttf|woff|woff2)$/,
        loader  : 'url?limit=90000'
      }
    ]
  },


   plugins: [
        new ExtractTextPlugin('main.css', {
            allChunks: true
        })
    ]
};

module.exports = config;

When i run "npm run watch" in terminal, webpack seems to begin normally just as it does with my working repo, except not looking for changes. Here is what it displays:

jordansykes  ~/sites/side-projects/mofilm
$ npm run watch

> donedone-api@1.0.0 watch /Users/jordansykes/Sites/side-projects/mofilm
> webpack --progress --colors --watch

Hash: f57ca91a3a54e729eb37
Version: webpack 1.13.1
Time: 789ms
  Asset     Size  Chunks             Chunk Names
main.js  1.45 kB       0  [emitted]  main
    + 1 hidden modules

Any help on this would be great. Thanks

Thanks for everyone's suggestions. Because I copied the repo in finder, .babelrc file that doesnt show up in finder, was not copied over. When this was created again in the root, everything compiled correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM