javascript webpackсборка
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript webpackсборка相关的知识,希望对你有一定的参考价值。
{
"name": "my-vue-app",
"description": "A Vue.js project",
"version": "1.0.0",
"author": "Evgeniy Larkov <elarkov@inbox.ru>",
"license": "MIT",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"normalize.css": "^7.0.0",
"pug": "^2.0.0-rc.4",
"sass-resources-loader": "^1.3.1",
"simple-vue-validator": "^0.14.2",
"svg-fill-loader": "0.0.8",
"vue": "^2.5.11",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-3": "^6.24.1",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"file-loader": "^1.1.4",
"node-sass": "^4.5.3",
"sass-loader": "^6.0.6",
"url-loader": "^0.6.2",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.9.1"
}
}
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: {
entry: './src/main.js',
styles: './src/styles/index.js'
},
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: '[name].bundle.js'
},
module: {
rules: [
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader'
],
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
esModule: false,
loaders: {
'scss': [
'vue-style-loader',
'css-loader',
'svg-fill-loader/encodeSharp',
'sass-loader',
{
loader: 'sass-resources-loader',
options: {
resources: [
'./src/styles/config/variables.scss',
'./src/styles/config/mixins.scss',
]
}
}
],
'sass': [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
]
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|woff|woff2)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
},
{
test: /\.svg$/,
use: [
'url-loader',
{
loader: 'svg-fill-loader?fill=#fff'
}
]
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
'styles': path.resolve(__dirname, 'src/styles/components'),
'img': path.resolve(__dirname, 'src/assets/img')
},
extensions: ['*', '.js', '.vue', '.json'],
modules: [
'node_modules',
path.resolve(__dirname, 'src/components')
]
},
devServer: {
historyApiFallback: true,
noInfo: false,
overlay: true,
open: false
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
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
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
以上是关于javascript webpackсборка的主要内容,如果未能解决你的问题,请参考以下文章
javascript Контрольчиславыбранныхчекбоксов
javascript Фиксацияблокаприскролле
javascript 对象中的道具排序(сортировкасвойтсвавобъекте)
javascript JS Sorax - Обработкаисключений
javascript 处理程序处理程序/Обработчикобработчикадлякорректногоудалениясобытий