-
抽离css
安装
npm install extract-text-webpack-plugin
查看全部 -
.babelrc
{ "presets":[ "env" ], "plugins":[ "transform-vue-jsx" ] }
查看全部 -
postcss.config.js
module.exports = { plugins: [ autoprefixer() ] }
查看全部 -
package.json
{ "name": "daya", "version": "1.0.0", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "cross-env NODE_ENV=production webpack --config webpack.config.js", "dev": "cross-env NODE_ENV=development webpack-dev-server --config webpack.config.js" }, "author": "chenyajie", "license": "ISC", "keywords": [ "daya" ], "description": "", "dependencies": { "autoprefixer": "^8.2.0", "babel-core": "^6.26.0", "babel-helper-vue-jsx-merge-props": "^2.0.3", "babel-loader": "^7.1.4", "babel-plugin-syntax-jsx": "^6.18.0", "babel-plugin-transform-vue-jsx": "^3.7.0", "babel-preset-env": "^1.6.1", "cross-env": "^5.1.4", "css-loader": "^0.28.11", "file-loader": "^1.1.11", "html-webpack-plugin": "^3.2.0", "js-loader": "^0.1.1", "postcss-loader": "^2.1.3", "style-loader": "^0.20.3", "stylus": "^0.54.5", "stylus-loader": "^3.0.2", "url-loader": "^1.0.1", "vue": "^2.5.16", "vue-loader": "^14.2.2", "vue-template-compiler": "^2.5.16", "webpack": "^4.5.0", "webpack-dev-server": "^3.1.3" }, "devDependencies": { "webpack-cli": "^2.0.14" } }
查看全部 -
webpack.config.js
const path = require("path"); const HTMLPlugin = require('html-webpack-plugin') const webpack = require("webpack") const isDev = process.env.NODE_ENV === "development"; var config = { "target" : "web", "entry": path.join(__dirname, "src/index.js"), "output": { filename: "bundle.js", path: path.join(__dirname, "dist"), }, mode: "development", module: { rules:[ { test: /\.vue$/, loader: "vue-loader" }, { test: /\.(js|jsx)$/, loader: "babel-loader" }, { test: /\.css$/, use:[ "style-loader", "css-loader" ] }, { test: /\.styl$/, use: [ "style-loader", 'css-loader', { loader:"postcss-loader", options:{ sourceMap: true } }, "stylus-loader" ] }, { test: /\.(jpg|png|gif|svg|jpeg)$/, use:[ { loader: "url-loader", options:{ limit: 1024, name:'[name]-aaa.[ext]' } } ] } ] }, plugins:[ new webpack.DefinePlugin({ 'process.env':{ NODE_ENV : isDev? '"development"' : '"production"' } }), new HTMLPlugin() ] } if(isDev){ config.devtool = "#cheap-module-eval-source-map"; config.devServer = { port: 8000, host:"0.0.0.0", overlay:{ errors: true }, // historyFallback: { // 没有映射的 // // }, hot: true // 热加载,只渲染改动过的 // open: true // 启动服务自动打开浏览器 }; // 热加载配置 config.plugins.push( new webpack.HotModuleReplacementPlugin(), new webpack.NoEmitOnErrorsPlugin() ); } module.exports = config
查看全部 -
npm i postcss-loader autoprefixer babel-loader babel-core
查看全部 -
package.json
{ "name": "daya", "version": "1.0.0", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "cross-env NODE_ENV=production webpack --config webpack.config.js", "dev": "cross-env NODE_ENV=development webpack-dev-server --config webpack.config.js" }, "author": "chenyajie", "license": "ISC", "keywords": [ "daya" ], "description": "", "dependencies": { "babel-loader": "^7.1.4", "cross-env": "^5.1.4", "css-loader": "^0.28.11", "file-loader": "^1.1.11", "html-webpack-plugin": "^3.2.0", "js-loader": "^0.1.1", "style-loader": "^0.20.3", "stylus": "^0.54.5", "stylus-loader": "^3.0.2", "url-loader": "^1.0.1", "vue": "^2.5.16", "vue-loader": "^14.2.2", "vue-template-compiler": "^2.5.16", "webpack": "^4.5.0", "webpack-dev-server": "^3.1.3" }, "devDependencies": { "webpack-cli": "^2.0.14" } }
查看全部 -
// webpack.config.js const path = require("path"); const HTMLPlugin = require('html-webpack-plugin') const webpack = require("webpack") const isDev = process.env.NODE_ENV === "development"; var config = { "target" : "web", "entry": path.join(__dirname, "src/index.js"), "output": { filename: "bundle.js", path: path.join(__dirname, "dist"), }, mode: "development", module: { rules:[ { test: /\.vue$/, loader: "vue-loader" }, { test: /\.js$/, loader: "babel-loader" }, { test: /\.css$/, use:[ "style-loader", "css-loader" ] }, { test: /\.styl$/, use: [ "style-loader", 'css-loader', "stylus-loader" ] }, { test: /\.(jpg|png|gif|svg|jpeg)$/, use:[ { loader: "url-loader", options:{ limit: 1024, name:'[name]-aaa.[ext]' } } ] } ] }, plugins:[ new webpack.DefinePlugin({ 'process.env':{ NODE_ENV : isDev? '"development"' : '"production"' } }), new HTMLPlugin() ] } if(isDev){ config.devtool = "#cheap-module-eval-source-map"; config.devServer = { port: 8000, host:"0.0.0.0", overlay:{ errors: true }, // historyFallback: { // 没有映射的 // // }, hot: true // 热加载,只渲染改动过的 // open: true // 启动服务自动打开浏览器 }; // 热加载配置 config.plugins.push( new webpack.HotModuleReplacementPlugin(), new webpack.NoEmitOnErrorsPlugin() ); } module.exports = config
查看全部 -
const path = require("path");
module.exports = {
"entry": path.join(__dirname, "src/index.js"),
"output": {
filename: "bundle.js",
path: path.join(__dirname, "dist"),
},
mode: "development",
module: {
rules:[{
test: /\.vue$/,
loader: "vue-loader"
},
{
test: /\.js$/,
loader: "babel-loader"
},
{
test: /\.css$/,
use:[
"style-loader",
"css-loader"
]
},
{
test: /\.styl$/,
use: [
"style-loader",
'css-loader',
"stylus-loader"
]
},
{
test: /\.(jpg|png|gif|svg|jpeg)$/,
use:[
{
loader: "url-loader",
options:{
limit: 1024,
name:'[name]-aaa.[ext]'
}
}
]
}
]
}
}
查看全部 -
webpack打包各种静态资源到一个加载类js里,从而操作这些资源
查看全部 -
将vue文件挂载到加载脚本节点上
查看全部 -
webpack打包前端资源,设置入口和出口,添加加载规则
查看全部 -
原来是高级课程,主要都是讲技巧,果断放弃了
好多知识不懂
查看全部 -
创建项目文件夹
查看全部 -
npm init
npm install webpack vue vue-loader --save-dev
npm install css=loader vue-template-compiler --save-dev
查看全部
举报