用于styles.css文件的Webpack提取文本插件有404错误

时间:2017-02-25 18:07:14

标签: css node.js webpack webpack-dev-server

这是我的webpack.config.js

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

module.exports = {
    // the main entry of our app
    entry: ['./src/index.js', './src/services/auth/index.js','./src/dist/js/drop-down.js'],
    // output configuration
    output: {
        path: __dirname + '/build/',
        publicPath: 'build/',
        filename: 'build.js'
    },

    module: {
        loaders: [
            // process *.vue files using vue-loader
            {test: /\.vue$/, loader: 'vue'},
            // process *.js files using babel-loader
            // the exclude pattern is important so that we don't
            // apply babel transform to all the dependencies!
            {test: /\.js$/, loader: 'babel', exclude: /node_modules/},

            {test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader")}
        ]
    },
    plugins: [
        new ExtractTextPlugin("styles.css")
    ],
    babel: {
        presets: ['es2015'],
        plugins: ['transform-runtime']
    }
};

我的package.json:

{
  "name": "somename",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "somelicense",
  "devDependencies": {
    "babel-core": "^6.1.2",
    "babel-loader": "^6.1.0",
    "babel-plugin-transform-runtime": "^6.1.2",
    "babel-preset-es2015": "^6.1.2",
    "babel-runtime": "^6.0.14",
    "css-loader": "^0.21.0",
    "extract-text-webpack-plugin": "^1.0.1",
    "style-loader": "^0.13.0",
    "vue-hot-reload-api": "^1.2.1",
    "vue-html-loader": "^1.0.0",
    "vue-loader": "^7.0.1",
    "webpack": "^1.12.3",
    "webpack-dev-server": "^1.12.1"
  },
  "dependencies": {
    "bootstrap": "^3.3.5",
    "vue": "^1.0.7",
    "vue-resource": "^0.1.17",
    "vue-router": "^0.7.5"
  }
}

这是我的目录结构:

enter image description here

当我运行webpack服务器时 webpack-dev-server --inline --hot

http://localhost:8080/build/styles.css

我收到404错误

有没有办法检查styles.css是否已生成?(可能是/build以外的其他地方)

如何修复此404错误?

0 个答案:

没有答案