vue-cnodejs学习-目录创建 环境配置

来源:互联网 发布:superslide.min.js 编辑:程序博客网 时间:2024/06/05 07:31

├── README.md
├── dist // 项目build目录
├── index.html // 项目入口文件
├── package.json // 项目配置文件
├── src // 生产目录
│ ├── assets // css js 和图片资源
│ ├── components // 各种组件
│ ├── views // 各种页面
│ ├── vuex // vuex状态管理器
│ ├── filters.js // 各种过滤器
│ └── main.js // Webpack 预编译入口
├── server.js // webpack-dev-server服务配置
└── webpack.config.js // Webpack 配置文件

webpack.config.js

'use strict'var path = require('path')var webpack = require('webpack')var ExtractTextPlugin = require('extract-text-webpack-plugin')var isProduction = () => {    return process.env.NODE_ENV === 'production'}var projectRoot = path.resolve(__dirname, './src')// webpack插件var plugins = [    // 提公用js到common.js文件中    new webpack.optimize.CommonsChunkPlugin('common.js'),    // 将样式统一发布到style.css中    new ExtractTextPlugin('style.css', {        allChunks: true,        disable: false    }),    // 使用 ProvidePlugin 加载使用率高的依赖库    new webpack.ProvidePlugin({        $: 'webpack-zepto'    })]let entry = ['./src/main']let cdnPrefix = ''let buildPath = '/dist/'let publishPath = cdnPrefix + buildPath    // 生产环境js压缩和图片cdnif (isProduction()) {    // plugins.push(new webpack.optimize.UglifyJsPlugin());    cdnPrefix = ''    publishPath = cdnPrefix}// 编译输出路径module.exports = {    debug: true,    entry: entry,    output: {        path: __dirname + buildPath,        filename: 'build.js',        publicPath: publishPath,        chunkFilename: '[id].build.js?[chunkhash]'    },    module: {        preLoaders: [{            test: /\.vue$/,            loader: 'eslint',            include: projectRoot,            exclude: /node_modules/        }, {            test: /\.js$/,            loader: 'eslint',            include: projectRoot,            exclude: /node_modules/        }],        loaders: [{            test: /\.vue$/,            loader: 'vue-loader'        }, {            test: /\.scss$/,            loader: ExtractTextPlugin.extract(                'style-loader', 'css-loader?sourceMap!sass-loader!autoprefixer?{browsers:["last 2 version", "> 1%"]}')        }, {            test: /\.css$/,            loader: ExtractTextPlugin.extract(                'style-loader', 'css-loader?sourceMap!cssnext-loader')        }, {            test: /\.js$/,            exclude: /node_modules|vue\/dist/,            loader: 'babel'        }, {            test: /\.(jpg|png|gif)$/,            loader: 'file-loader?name=images/[hash].[ext]'        }, {            test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,            loader: 'url-loader?limit=10000&minetype=application/font-woff'        }, {            test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,            loader: 'file-loader'        }, {            test: /\.json$/,            loader: 'json'        }, {            test: /\.(html|tpl)$/,            loader: 'html-loader'        }]    },    resolve: {        // require时省略的扩展名,如:require('module') 不需要module.js        extension: ['', '.js'],        // 别名        alias: {            filter: path.join(__dirname, 'src/filters'),            vue: 'vue/dist/vue.js'        }    },    plugins: plugins,    devtool: '#source-map'}
0 0
原创粉丝点击