|
@@ -0,0 +1,76 @@
|
|
|
+
|
|
|
+const {resolve} = require('path');
|
|
|
+const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
+
|
|
|
+module.exports = {
|
|
|
+ entry : ['./src/js/index.js','./src/index.html'],
|
|
|
+ output:{
|
|
|
+ filename: 'js/built.js',
|
|
|
+ path: resolve(__dirname,'build')
|
|
|
+ },
|
|
|
+ module:{
|
|
|
+ rules:[
|
|
|
+ //less
|
|
|
+ {
|
|
|
+ test:/\.less$/,
|
|
|
+ use:['style-loader','css-loader','less-loader']
|
|
|
+ },
|
|
|
+ //css
|
|
|
+ {
|
|
|
+ test:/\.css$/,
|
|
|
+ use:['style-loader','css-loader']
|
|
|
+ },
|
|
|
+ //图片
|
|
|
+ {
|
|
|
+ test: /\.(jpg|jpeg|png|gif)$/,
|
|
|
+ loader: 'url-loader',
|
|
|
+ options:{
|
|
|
+ limit:8*1024,
|
|
|
+ name:'[hash:10].[ext]',
|
|
|
+ esModule:false,
|
|
|
+ outputPath: 'imgs'
|
|
|
+ },
|
|
|
+ type:'javascript/auto'
|
|
|
+ },
|
|
|
+ //html
|
|
|
+ {
|
|
|
+ test:/\.html$/,
|
|
|
+ loader: 'html-loader'
|
|
|
+ },
|
|
|
+ //其他
|
|
|
+ {
|
|
|
+ exclude:/\.(html|js|css|less|jpg|jpeg|png|gif)$/,
|
|
|
+ loader:'file-loader',
|
|
|
+ options:{
|
|
|
+ name:'[hash:10].[ext]',
|
|
|
+ esModule:false,
|
|
|
+ outputPath: 'media'
|
|
|
+ },
|
|
|
+ type:'javascript/auto'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ plugins:[
|
|
|
+ new HtmlWebpackPlugin({
|
|
|
+ template:'./src/index.html'
|
|
|
+ })
|
|
|
+ ],
|
|
|
+ mode: 'development',
|
|
|
+ devServer:{
|
|
|
+ contentBase:resolve(__dirname,'build'),
|
|
|
+ compress:true,
|
|
|
+ port:3000,
|
|
|
+ open:true,
|
|
|
+ hot:true
|
|
|
+ },
|
|
|
+ target: "web", //可以解决browserslist 导致 webpack-dev-server 的自动刷新失效
|
|
|
+ /**
|
|
|
+ * source-map: 外部
|
|
|
+ * inline-source-map: 内联
|
|
|
+ * hidden-source-map: 外部
|
|
|
+ * eval-source-map: 内联
|
|
|
+ * nosources-source-map: 外部
|
|
|
+ * cheap-source-map: 外部
|
|
|
+ * cheap-module-source-map: 外部
|
|
|
+ */
|
|
|
+}
|