我为一个使用webpack并完美运行的项目设置了一个repo。我复制了整个仓库来开始一个新项目。现在当我跑步" npm run watch" webpack启动但不会注意更改。我的package.json文件如下所示:
{
"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"
}
}
和我的webpack配置如下:
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;
当我跑步" npm run watch"在终端中,webpack似乎正常开始,就像我的工作回购一样,除了不寻找更改。以下是它显示的内容:
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
对此的任何帮助都会很棒。感谢
答案 0 :(得分:0)
感谢大家的建议。因为我在finder中复制了repo,所以没有在finder中显示的.babelrc文件没有复制过来。当在根中再次创建它时,一切都正确编译。