一切运行正常,但无法找到我的dist文件夹的位置。我按照文档使用publicPath,仍然是dist文件夹似乎来自内存。
这可能是一个小问题,我是webpack的新手。任何帮助都可以使用
下面是我的webpack.config.js文件
var path = require('path')
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: "./src/index.js",
output: {
path: path.join(__dirname,'dist'),
filename: "[name].js",
publicPath:'/dist'
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
})
],
module: {
loaders: [
{
test: /\.css$/, loader: "style-loader!css-loader"
},
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpg)$/,
loader: 'url-loader?limit=30000&name=[name]-[hash].[ext]'
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel',
query: {
presets: ['es2015', 'react', 'stage-2']
}
}
]
},
devServer: {
historyApiFallback: true,
stats:'error-only'
}
};
我的package.json文件是
{
"name": "tryout",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha './tests/**/*.test.js' --compilers js:babel-core/register --recursive",
"start-dev-server": "webpack-dev-server --content-base dist/ --port 6969",
"s": "npm run start-dev-server",
"test:watch": "npm test -- --watch"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.13.2",
"babel-loader": "^6.2.4",
"babel-polyfill": "^6.13.0",
"babel-preset-es2015": "^6.13.2",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-2": "^6.13.0",
"es6-promise": "^3.2.1",
"file-loader": "^0.9.0",
"html-webpack-plugin": "^2.22.0",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.15.0",
"react": "^15.3.0",
"react-dom": "^15.3.0",
"react-redux": "^4.4.5",
"react-router": "^2.6.1",
"react-router-redux": "^4.0.5",
"redux": "^3.5.2",
"redux-thunk": "^2.1.0",
"url-loader": "^0.5.7",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
},
"devDependencies": {
"babel-register": "^6.11.6",
"css-loader": "^0.23.1",
"enzyme": "^2.4.1",
"expect": "^1.20.2",
"mocha": "^3.0.2",
"nock": "^8.0.0",
"react-addons-test-utils": "^15.3.1",
"redux-mock-store": "^1.1.4",
"style-loader": "^0.13.1"
}
}
答案 0 :(得分:24)
仍然是dist文件夹似乎来自内存
很有可能是因为您正在使用webpack-dev-server
(这就是它的作用)。
如果您希望将捆绑的资产实际写入磁盘,请运行webpack
。