一直卡在这里...
const webpack = require('webpack');
const UglifyJSPlugin = require("uglifyjs-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
module.exports = {
entry: "./src/main.js",
output: {
filename: "D:/workspace/aa/WebContent/static/bb/js/build.js"
},
module: {
loaders : [
{
test : /\.scss$/,
loader : ExtractTextPlugin.extract({
use:[
{
loader: 'css-loader'
},
{
loader:'sass-loader'
}
]
})
}
]
},
resolve: {
extensions: [ '.js', '.jsx']
},
plugins: [new webpack.BannerPlugin("xxx.com"),new UglifyJSPlugin(),new OptimizeCSSPlugin(),new ExtractTextPlugin("D:/workspace/aa/WebContent/static/bb/css/style.css")]
};
我改了filename的路径和ExtractTextPlugin的样式路径..
以下是正常的
const webpack = require('webpack');
const UglifyJSPlugin = require("uglifyjs-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
module.exports = {
entry: "./src/main.js",
output: {
filename: "build/build.js"
},
module: {
loaders : [
{
test : /\.scss$/,
loader : ExtractTextPlugin.extract({
use:[
{
loader: 'css-loader'
},
{
loader:'sass-loader'
}
]
})
}
]
},
resolve: {
extensions: [ '.js', '.jsx']
},
plugins: [new webpack.BannerPlugin("xxx.com"),new UglifyJSPlugin(),new OptimizeCSSPlugin(),new ExtractTextPlugin("build/style.css")]
};
这样就可以打包成功
D:/workspace/aa/WebContent 是我的eclipse的项目路径
因为我用eclipse开发java项目,我不想每次修改静态样式 ,js文件后,手动把打包好的文件,又覆盖到eclipse项目的WebContent里.有什么办法吗?
可以用 node 中的
path
对象,path.join(__dirname, '..', dir)
,dir
相对于当前路径