我有一个Angular2 webpack项目,在本地工作正常(webpack-dev-server),但是一旦我部署到我的服务器(Apache),并运行“npm运行构build”,构build不会更新(不显示错误)。尝试删除我的dist文件夹,但仍然没有change.No更改为HTML显示(这是工作完美的罚款之前)
webpack.config.js – >
var path = require('path'), webpack = require('webpack'), HtmlWebpackPlugin = require('html-webpack-plugin'), CopyWebpackPlugin = require('copy-webpack-plugin'); module.exports = { entry: { app: './src/main' }, output: { path: path.resolve(__dirname, './dist'), filename: 'app.bundle.js' }, resolve: { extensions: ['.js', '.ts','.tsx', '.css', '.scss', '.html'] }, module: { rules: [{ test: /\.ts$/, use: ['awesome-typescript-loader', 'angular2-template-loader', '@angularclass/hmr-loader', 'angular2-router-loader'], exclude: [/\.(spec|e2e)\.ts$/, /node_modules\/(?!(ng2-.+))/] }, { test: /\.scss$/, exclude: [/node_modules/], use: [ 'raw-loader', 'sass-loader', { loader: 'sass-resources-loader', options: { // Or array of paths resources: [ './src/assets/sharedStyles/_variables.scss', './src/assets/sharedStyles/_mixins.scss' ] }, } ] }, { test: /\.css$/, use: ['style-loader', 'css-loader'] }, { test: /\.html$/, loader: 'raw-loader' }, { test: /\.(eot|ttf|wav|mp3|pdf|woff2|woff|png|svg|gif)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file-loader' } ] }, // plugins plugins: [ new webpack.ContextReplacementPlugin( // The (\\|\/) piece accounts for path separators in *nix and Windows /angular(\\|\/)core(\\|\/)@angular/, __dirname // location of your src ), new HtmlWebpackPlugin({ template: './src/index.html', chunksSortMode: 'dependency' }), new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }), new CopyWebpackPlugin([{ from: './src/assets', to: './assets', copyUnmodified: true, force: true }]) ], devServer: { contentBase: path.join(__dirname, "src/"), compress: true, port: 3000, historyApiFallback: true, inline: true } };
的package.json – >
{ "name": "App", "version": "1.0.0", "scripts": { "postinstall": "typings install", "typings": "typings", "start": "webpack-dev-server --public --port 3000 --hot --host 0.0.0.0", "build": "webpack", "build-prod": "webpack -p" }, "licenses": [ { "type": "MIT", "url": "https://github.com/angular/angular.io/blob/master/LICENSE" } ], "dependencies": { "@angular/animations": "^4.1.2", "@angular/common": "^4.1.2", "@angular/compiler": "^4.1.2", "@angular/compiler-cli": "^4.1.2", "@angular/core": "^4.1.2", "@angular/forms": "^4.1.2", "@angular/http": "^4.1.2", "@angular/platform-browser": "^4.1.2", "@angular/platform-browser-dynamic": "^4.1.2", "@angular/platform-server": "^4.1.2", "@angular/router": "^4.1.2", "@angular/upgrade": "4.1.2", "angular-in-memory-web-api": "~0.1.5", "bootstrap": "^3.3.7", "core-js": "^2.4.1", "d3": "^4.9.1", "html-webpack-plugin": "^2.28.0", "jquery": "2.xx", "jquery-ui": "^1.10.3", "jquery-ui-npm": "^1.12.0", "ngx-bootstrap": "^1.6.6", "primeui": "^4.1.15", "reflect-metadata": "0.1.9", "rxjs": "5.1.0", "systemjs": "0.19.39", "typescript": "^2.4.1", "zone.js": "0.7.2" }, "devDependencies": { "@angularclass/hmr-loader": "^3.0.2", "@types/jquery": "^2.0.33", "angular2-router-loader": "^0.3.4", "angular2-template-loader": "^0.6.2", "awesome-typescript-loader": "^3.0.3", "concurrently": "^3.0.0", "copy-webpack-plugin": "^4.0.1", "css-loader": "^0.26.1", "extract-text-webpack-plugin": "^1.0.1", "file-loader": "^0.10.1", "google-maps": "^3.2.1", "lite-server": "^2.2.2", "ng2-cookies": "^1.0.6", "ng2-datetime": "1.2.1", "ng2-popover": "0.0.13", "node-sass": "^4.5.0", "primeng": "^4.1.0-rc.2", "primeui": "^4.1.15", "raw-loader": "^0.5.1", "sass-loader": "^6.0.0", "sass-resources-loader": "^1.2.0", "smartadmin-plugins": "^1.0.15", "style-loader": "^0.13.2", "to-string-loader": "^1.1.5", "ts-loader": "^2.0.0", "typings": "2.1.0", "webpack": "^2.2.1", "webpack-dev-server": "^2.3.0" } }