You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/webpack.config.js

136 lines
5.0 KiB

8 years ago
var path = require('path');
var HtmlWebPackPlugin = require("html-webpack-plugin");
7 years ago
var AddAssetHtmlPlugin = require("add-asset-html-webpack-plugin");
7 years ago
var ExtractTextPlugin = require('extract-text-webpack-plugin');
7 years ago
const webpack = require('webpack');
var OpenBrowserPlugin = require('open-browser-webpack-plugin');
function getpath(fileName)
{
return path.resolve(__dirname, fileName);
}
8 years ago
module.exports = {
entry: "./src/index.tsx",
8 years ago
output: {
path: path.join(__dirname, "dist"),
filename: '[name].js',
publicPath: '/',
hotUpdateChunkFilename: 'hot/[id].[hash].hot-update.js',
hotUpdateMainFilename: 'hot/[hash].hot-update.json'
8 years ago
},
// Enable sourcemaps for debugging webpack's output.
devtool: "source-map",
resolve: {
alias: {
"dat.gui": getpath('./node_modules/dat.gui/build/dat.gui.js'),
"three-FBXLoader": getpath("./src/Loader/FBXLoader.js"),
"zlib": getpath("./node_modules/three/examples/js/libs/inflate.min.js"),
"three-CopyShader": getpath("./node_modules/three/examples/js/shaders/CopyShader.js"),
"three-SMAAShader": getpath("./node_modules/three/examples/js/shaders/SMAAShader.js"),
"three-FXAAShader": getpath("./node_modules/three/examples/js/shaders/FXAAShader.js"),
"three-OutlinePass": getpath("./src/GraphicsSystem/OutlinePass.js"),
"three-EffectComposer": getpath("./node_modules/three/examples/js/postprocessing/EffectComposer.js"),
"three-RenderPass": getpath("./node_modules/three/examples/js/postprocessing/RenderPass.js"),
"three-ShaderPass": getpath("./node_modules/three/examples/js/postprocessing/ShaderPass.js"),
"three-ShaderPass": getpath("./node_modules/three/examples/js/postprocessing/ShaderPass.js"),
"three-SMAAPass": getpath("./node_modules/three/examples/js/postprocessing/SMAAPass.js"),
// "stats-js": getpath('./node_modules/stats.js/src/stats.js'),
"three-Reflector": getpath("./src/objects/Reflector.js"),
},
8 years ago
// Add '.ts' and '.tsx' as resolvable extensions.
7 years ago
extensions: [".ts", ".tsx", ".js", "json"]
8 years ago
},
module: {
loaders: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
7 years ago
{ test: /\.[(png)|(jpg)|(obj)]$/, loader: "file-loader" },
//样式加载 css
7 years ago
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
// use: ExtractTextPlugin.extract({
// use: 'css-loader'
// })
},
//样式加载 less
{
test: /\.less$/,
use:
[
{
loader: "style-loader"
},
{
loader: "css-loader"
},
{
loader: "less-loader", options:
{
strictMath: true,
noIeCompat: true
}
}
]
},
//字体加载 blueprint
{
test: /\.(ttf|eot|svg)$/,
use: {
loader: 'file-loader',
options: {
name: 'fonts/[hash].[ext]'
}
}
},
//字体加载 blueprint
{
test: /\.(woff|woff2)$/,
use: {
loader: 'url-loader',
options: {
name: 'fonts/[hash].[ext]',
limit: 5000,
mimetype: 'application/font-woff'
}
}
},
7 years ago
]
8 years ago
},
// Other options...
devServer: {
contentBase: path.join(__dirname, "dist"),
port: 7777,
hot: true
},
7 years ago
plugins: [
new HtmlWebPackPlugin(
{
title: "webCAD",
template: 'index.html'
}),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.DllReferencePlugin({
context: '.',
manifest: require(getpath("./manifest.json"))
}),
new AddAssetHtmlPlugin({ filepath: getpath("./dist/dll.js") }),
// new ExtractTextPlugin({ filename: 'styles.css' }),
7 years ago
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
ReactDOM: 'react-dom',
React: 'react',
THREE: "three",
Zlib: "zlib"
7 years ago
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new OpenBrowserPlugin({
url: 'http://localhost:7777/'
})
7 years ago
]
8 years ago
};