账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    extract-text-webpack-plugin打包.vue文件中的styl部分生成一个css是文件失败
    41
    0

    这是webpack.config.js

    const path = require('path');
    const HtmlWebpackPlugin = require('html-webpack-plugin');
    const CleanWebpackPlugin = require('clean-webpack-plugin');
    const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
    const ExtractTextPlugin = require("extract-text-webpack-plugin")
    const webpack = require('webpack');
    
    module.exports = {
        entry: {
            coco: './src/main.js'
        },
        devtool: 'inline-source-map',
        output: {
            filename: '[hash].js',
            path: path.resolve(__dirname, 'dist'),
            publicPath: '/'
        },
        devServer: {
            contentBase: './dist',
            hot: true
        },
        module: {
            rules: [{
                    test: /\.(png|svg|jpg|gif|woff|woff2|eot|ttf|otf)$/,
                    use: ['file-loader']
                },
                {
                    test: /\.vue$/,
                    exclude: /node_modules/,
                    use: [{
                        loader: 'vue-loader',
                        options: {
                            loaders: {
                                use: ExtractTextPlugin.extract({
                                    fallback: 'style-loader',
                                    use: ['css-loader', 'stylus-loader']
                                })
                            }
                        }
                    }]
                }, {
                    test: /\.(css|styl)$/,
                    use: ExtractTextPlugin.extract({
                        fallback: 'style-loader',
                        use: ['css-loader', 'stylus-loader']
                    })
                },
                //  {
                //     enforce: "pre",
                //     test: /\.js$/,
                //     exclude: /node_modules/,
                //     loader: "eslint-loader",
                //     options: {
    
                //     }
                // }, 
                {
                    test: /\.js$/,
                    exclude: /(node_modules|bower_components)/,
                    use: {
                        loader: 'babel-loader',
                        options: {
                            presets: ['env']
                        }
                    }
                }
            ]
        },
        plugins: [
            new UglifyJSPlugin(),
            new CleanWebpackPlugin(['dist']),
            new HtmlWebpackPlugin({
                title: 'coding',
                template: path.resolve(__dirname, './index.html'),
                // filename: 'coco.html',
                favicon: './src/images/OEM/coco.ico',
                hash: true,
                cache: true,
                showErrors: true
            }),
            new ExtractTextPlugin({
                filename: 'styles.css',
                allChunks: true,
            }),
            new webpack.NamedModulesPlugin(),
            new webpack.HotModuleReplacementPlugin()
        ],
        resolve: {
            extensions: ['.js', '.vue', '.json'],
            alias: {
                'vue': 'vue/dist/vue.js'
            }
        }
    };

    大神帮忙看一眼有哪里不对吗(build和run都没有报错.)

    2
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部