webpack 3.6.0版本
module:{
loaders:[
{
test: /\.js$/,
loader: 'babel-loader',
exclude: __dirname + '/node_modules/',
include: __dirname + '/src/',
query: {
presets: ['latest']
}
}
]
}
module:{
loaders:[
{
test: /\.js$/,
loader: 'babel-loader',
exclude: __dirname + '/node_modules/',
include: __dirname + '/src/',
query: {
presets: ['latest']
}
}
]
}
2017-10-03
webpack 3.6.0版本:
var htmlWebpackPlugin = require('html-webpack-plugin');
const config={
entry: {
main: './src/script/main.js',
a: './src/script/a.js'
},
output:{
path:__dirname+'/dist/js',
filename:'[hash].js'
},
plugins:[
new htmlWebpackPlugin()
]
}
module.exports=config;
var htmlWebpackPlugin = require('html-webpack-plugin');
const config={
entry: {
main: './src/script/main.js',
a: './src/script/a.js'
},
output:{
path:__dirname+'/dist/js',
filename:'[hash].js'
},
plugins:[
new htmlWebpackPlugin()
]
}
module.exports=config;
2017-10-03
在使用exclude时,参数配置如下:
exclude: ['/node_modules']
这样才是node_modules的绝对路径
exclude: ['/node_modules']
这样才是node_modules的绝对路径
2017-10-01
webpack3以上的loader的配置如下:
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
'presets': ['env']
}
}
]
}
需要注意的是:要安装env,安装方法:npm install --save-dev babel-preset-env
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
'presets': ['env']
}
}
]
}
需要注意的是:要安装env,安装方法:npm install --save-dev babel-preset-env
2017-10-01
如果你的webpack不是全局安装的,那么当你在终端中使用此命令时,需要额外指定其在node_modules中的地址,继续上面的例子,在终端中输入如下命令
# webpack非全局安装的情况
node_modules/.bin/webpack hello.js hello.bundle.js
# webpack非全局安装的情况
node_modules/.bin/webpack hello.js hello.bundle.js
2017-09-30
output这样配置就不会报错:
module.exports = {
entry: './src/script/main.js',
output: {
path: __dirname + '/dist/js',
filename: 'bundle.js'
}
}
module.exports = {
entry: './src/script/main.js',
output: {
path: __dirname + '/dist/js',
filename: 'bundle.js'
}
}
2017-09-30
唯一的地方注意下:安装file-loader的版本
cnpm i --save-dev file-loader@0.9.0
cnpm i --save-dev file-loader@0.9.0
2017-09-30
安装node-sass
{test:/\.(css|less|scss)$/,
//loader:'style!css!postcss'//
use:['style-loader','css-loader',
{loader:'postcss-loader',
options:{
plugins:[require('postcss-import'),require('autoprefixer')],
browser:['last 5 versions']
}
},'less-loader','sass-loader'
]
}
{test:/\.(css|less|scss)$/,
//loader:'style!css!postcss'//
use:['style-loader','css-loader',
{loader:'postcss-loader',
options:{
plugins:[require('postcss-import'),require('autoprefixer')],
browser:['last 5 versions']
}
},'less-loader','sass-loader'
]
}
2017-09-29
新版本测试有效:
{test:/\.css$/,
//loader:'style-loader!css-loader'//从右到左解析
use:['style-loader','css-loader',
{
loader:'postcss-loader',
options:{
plugins:[require('postcss-import'),require('autoprefixer')],
browser:['last 5 versions']
}
}
]
}
{test:/\.css$/,
//loader:'style-loader!css-loader'//从右到左解析
use:['style-loader','css-loader',
{
loader:'postcss-loader',
options:{
plugins:[require('postcss-import'),require('autoprefixer')],
browser:['last 5 versions']
}
}
]
}
2017-09-29
may only appear at the top level (8:0) webpack打包出错,提示这个,怎么回事啊?谢谢
2017-09-29