|
@@ -0,0 +1,24 @@
|
|
|
+const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
|
|
+const path = require("path");
|
|
|
+module.exports = {
|
|
|
+ mode: "development", //打包为开发模式
|
|
|
+ entry: "./src/main", //入口文件,从项目根目录指定
|
|
|
+ output: { //输出路径和文件名,使用path模块resolve方法将输出路径解析为绝对路径
|
|
|
+ path: path.resolve(__dirname, "../dist/js"), //将js文件打包到dist/js的目录
|
|
|
+ filename: "main.js"
|
|
|
+ },
|
|
|
+ module: {
|
|
|
+ rules: [
|
|
|
+ {
|
|
|
+ test: /\.css$/,
|
|
|
+ use: ExtractTextPlugin.extract({
|
|
|
+ fallback: "style-loader",
|
|
|
+ use: "css-loader"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ plugins: [
|
|
|
+ new ExtractTextPlugin("../css/styles.css") //默认其实目录问打包后的入口文件路径,所以需要../
|
|
|
+ ]
|
|
|
+}
|