美文网首页
Webpack Vonic

Webpack Vonic

作者: solaman | 来源:发表于2017-06-14 17:34 被阅读0次

    webpack.config.js内容如下

    ```

    var path = require('path')

    var webpack = require('webpack')

    module.exports = {

    entry: './src/main.js',

    output: {

    path: path.resolve(__dirname, './dist/js'),

    publicPath: 'js/',

    filename: 'build.js'

    },

    module: {

    rules: [

    {

    test: /\.vue$/,

    loader: 'vue-loader',

    options: {

    loaders: {

    scss: 'vue-style-loader!css-loader!sass-loader'

    }

    }

    },

    {

    test: /\.js$/,

    loader: 'babel-loader',

    query: {

    presets: ['es2015']

    }

    },

    {

    test: /\.scss$/,

    loader: 'style-loader!css-loader!sass-loader'

    },

    {

    test: /\.(png|jpg|gif|svg)|((eot|woff|ttf|svg)[\?]?.*)$/,

    loader: 'url-loader',

    query: {

    limit: 10000,

    name: '[name].[ext]?[hash]'

    }

    }

    ]

    },

    resolve: {

    extensions: ['.js', '.vue'],

    alias: {

    'vue$': 'vue/dist/vue.common.js'

    }

    },

    devServer: {

    historyApiFallback: true,

    noInfo: true

    },

    devtool: '#eval-source-map',

    plugins: [

    new webpack.ProvidePlugin({

    axios: "axios"

    })

    ]

    }

    if (process.env.NODE_ENV === 'production') {

    module.exports.devtool = '#source-map'

    // http://vue-loader.vuejs.org/en/workflow/production.html

    module.exports.plugins = (module.exports.plugins || []).concat([

    new webpack.DefinePlugin({

    'process.env': {

    NODE_ENV: '"production"'

    }

    }),

    new webpack.optimize.UglifyJsPlugin({

    sourceMap: true,

    compress: {

    warnings: false

    }

    })

    ])

    }

    ```

    package.json内容如下

    ```

    {

    "name": "vonic-template",

    "version": "2.0.0",

    "description": "Webpack Template for Vonic 2.",

    "author": "wangdahoo <157195705@qq.com>",

    "scripts": {

    "dev": "webpack-dev-server --content-base src/ --inline --hot --port=3001",

    "build": "cross-env NODE_ENV=production webpack --progress --hide-modules"

    },

    "dependencies": {

    "axios": "^0.15.3",

    "babel-plugin-transform-runtime": "^6.23.0",

    "babel-preset-env": "^1.4.0",

    "babel-preset-stage-2": "^6.24.1",

    "sass-loader": "^4.1.1",

    "vonic": "^2.0.0-rc.1",

    "vue": "^2.2.5",

    "vue-router": "^2.3.0"

    },

    "devDependencies": {

    "babel-core": "^6.0.0",

    "babel-loader": "^6.0.0",

    "babel-preset-es2015": "^6.0.0",

    "cross-env": "^3.0.0",

    "css-loader": "^0.25.0",

    "file-loader": "^0.9.0",

    "node-sass": "^3.9.3",

    "sass-loader": "^4.0.2",

    "style-loader": "^0.13.1",

    "url-loader": "^0.5.7",

    "vue-loader": "^11.0.0",

    "vue-template-compiler": "^2.2.5",

    "webpack": "^2.2.0",

    "webpack-dev-server": "^2.3.0"

    }

    }

    ```

    相关文章

      网友评论

          本文标题:Webpack Vonic

          本文链接:https://www.haomeiwen.com/subject/qnheqxtx.html