webpack.dev.js 871 B

123456789101112131415161718192021222324
  1. const ExtractTextPlugin = require("extract-text-webpack-plugin");
  2. const path = require("path");
  3. module.exports = {
  4. mode: "development", //打包为开发模式
  5. entry: "./src/main", //入口文件,从项目根目录指定
  6. output: { //输出路径和文件名,使用path模块resolve方法将输出路径解析为绝对路径
  7. path: path.resolve(__dirname, "../dist/js"), //将js文件打包到dist/js的目录
  8. filename: "main.js"
  9. },
  10. module: {
  11. rules: [
  12. {
  13. test: /\.css$/,
  14. use: ExtractTextPlugin.extract({
  15. fallback: "style-loader",
  16. use: "css-loader"
  17. })
  18. }
  19. ]
  20. },
  21. plugins: [
  22. new ExtractTextPlugin("../css/styles.css") //默认其实目录问打包后的入口文件路径,所以需要../
  23. ]
  24. }