123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- 'use strict'
- const webpack = require('webpack')
- const path = require('path')
- const utils = require('./utils')
- const config = require('../config')
- const vueLoaderConfig = require('./vue-loader.conf')
- //头部引入css打包插件
- const ExtractTextPlugin = require("extract-text-webpack-plugin");
- const CleanWebpackPlugin = require("clean-webpack-plugin")
- var projectRoot = path.resolve(__dirname, '../')
- function resolve (dir) {
- return path.join(__dirname, '..', dir)
- }
- module.exports = function(baseOption)
- {
- return {
- entry: {
- app: ['babel-polyfill','./src/main.js'],
- },
- plugins: [
- new webpack.ProvidePlugin({
- $: "jquery",
- jQuery:"jquery",
- "window.jQuery":"jquery"
- }),
- new CleanWebpackPlugin(
- ['dist/*'], //匹配删除的文件
- {
- root: path.resolve(__dirname, '../'), //根目录
- verbose: true, //开启在控制台输出信息
- dry: false //启用删除文件
- }
- ),
- ],
- output: {
- path: config.build.assetsRoot,
- filename: '[name].js',
- publicPath: process.env.NODE_ENV === 'production'
- ? config.build.assetsPublicPath
- : config.dev.assetsPublicPath
- },
- resolve: {
- extensions: ['.js', '.vue', '.json'],
- alias: {
- 'vue$': 'vue/dist/vue.esm.js',
- 'alte':'admin-lte/dist',
- 'alt-plugin':'admin-lte/plugins',
- '@': resolve('src')
- }
- },
- module: {
- rules: [
- {
- test: /\.vue$/,
- use:[{
- loader: 'vue-loader',
- options: vueLoaderConfig(baseOption)
- },{
- loader: 'iview-loader',
- options: {
- prefix: false
- }
- }]
- },
- {
- test: /\.js$/,
- loader: 'babel-loader',
- include: [projectRoot,resolve('/node_modules/iview/src/components/table/expand.js')],
- exclude: /node_modules/
- },
- //{
- // test: /\.css$/,
- // //请注意loader里的写法,有一些低版本的例子中是过时的写法
- // loader: ExtractTextPlugin.extract({
- // fallback: "style-loader",
- // use: "css-loader"
- // })
- //},
- {
- test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- name: utils.assetsPath('img/[name].[hash:7].[ext]')
- }
- },
- {
- test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- name: utils.assetsPath('media/[name].[hash:7].[ext]')
- }
- },
- {
- test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
- }
- }
- ]
- }
- }
- }
|